-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ron Arts wrote:
> Is there a (relatively easy) way to hack up a function call that would
> just retrieve one record by it's oid (primary integer key), and return it
> in a form that would allow using the sqlite3_columm() functions?
> 
> Something along the lines of:
> 
>    sqlite3_prepare(db, "select * from company where id = 1", -1, &stmt, NULL);
>    rc = sqlite3_get_byoid(stmt, oid);
>    id = sqlite3_column_int(stmt, 0);

  -- to find the rowid
  prepare("select _rowid_, * from .....")
  -- to find the record later
  prepare("select * from ... where _rowid_=?", rowid)

> I need to speed up record retrieval from a in-memory database, and I know
> beforehand that 99% of my queries involve retrieving one record by primary
> integer key.

In that case the primary integer key column is the same as rowid.  See
http://www.sqlite.org/autoinc.html

Searching for the rowid should translate into a btree search. Do you have
any evidence that isn't happening?

Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkraR+IACgkQmOOfHg372QT1kQCgvHP97xily5jZaNYK0QxJxtRM
+Q4An0XR6wsCct9M1M9Py7Q6B1tJoo+O
=uMwg
-----END PGP SIGNATURE-----
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to