On Thu, Mar 8, 2012 at 8:02 AM, Igor Tandetnik <itandet...@mvps.org> wrote:
> You can implement this algorithm in your application's code, if you are so 
> inclined. Just prepare a query lile
>
> select * from the_table where rowid=?;
>
> then run it N times, binding different random numbers to the parameter. Of 
> course you still need to deal with the two issues I mentioned above (perhaps 
> you know that in your particular application, rowids are always sequential).

There's probably no good way to do this, sadly.  The distribution of
results with your approach depends on the distribution of rowids.
Suppose the btree interfaces in SQLite3 provided an interface for
picking a random row from a random page in a table (meaning, use
random numbers to walk down the b-tree)... but then the distribution
of results would depend on the distribution of row sizes and on the
distribution of unallocated space in b-tree pages.

But at least with your approach the OP can make sure that all rowids
are contiguous, then it works out.

Nico
--
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to