I have a table with millions of records.
When I run a query with
ORDER BY random() LIMIT N;
the RANDOM() function is evaluated against all rows of my result set,
then sorting occurs, and as a result the query is slow.
In this case the query could be rewritten as:
* Generate N, random,
of SQLite Database
Subject: EXT :[sqlite] Efficient random sampling in a large table using builtin
functions.
I have a table with millions of records.
When I run a query with
ORDER BY random() LIMIT N;
the RANDOM() function is evaluated against all rows of my result set,
then sorting occurs
On 8 March 2012 14:20, Black, Michael (IS) michael.bla...@ngc.com wrote:
You don't say what language you are working in. IN C++ I would just declare
a set and put random row numbers in it until I had enough. Then use that
set to build the SQL.
SQLite's random() doesn't have a seed
] Efficient random sampling in a large table using
builtin functions.
On 8 March 2012 14:20, Black, Michael (IS) michael.bla...@ngc.com wrote:
You don't say what language you are working in. IN C++ I would just declare
a set and put random row numbers in it until I had enough. Then use that
set
...@sqlite.org] on
behalf of Simon Davies [simon.james.dav...@gmail.com]
Sent: Thursday, March 08, 2012 8:33 AM
To: General Discussion of SQLite Database
Subject: EXT :Re: [sqlite] Efficient random sampling in a large table using
builtin functions.
On 8 March 2012 14:20, Black, Michael
[simon.james.dav...@gmail.com]
Sent: Thursday, March 08, 2012 8:47 AM
To: General Discussion of SQLite Database
Subject: EXT :Re: [sqlite] Efficient random sampling in a large table using
builtin functions.
On 8 March 2012 14:37, Black, Michael (IS) michael.bla...@ngc.com wrote:
Glad to know