inside Habbie's mind

Entries tagged “sql”

scrolling in large resultsets with SQL

written by peter, on Oct 8, 2007 7:48:00 AM.

This article on the SQLite wiki details how to efficiently maintain a small window on a big dataset without sacrificing performance, in environments that cannot maintain actual cursors, or where doing so is prohibitively expensive. Rule 2 in the article applies to other databases too; the method detailed in the article applies to any database in which keeping cursors is either impossible or expensive.

The article seems obvious; but I had not actually thought of that approach myself, so far.

SQL debugging tip

written by peter, on Aug 11, 2006 3:46:00 PM.

When you’re using a lot of SQL from a programming language (be it PHP or C++), put comments inside all your queries indicating which function executed them. That way, logging becomes much more useful, like this:

sqlite3_trace: SELECT /* createobject uniquecontext */
   content FROM objects WHERE id=4

(I did not come up with this trick - but it is useful enough to post here anyway.)