hmm... i think: begin transaction; query 'select count(*) from tab' to get total number of records, name it N randomly select 200 integers from the range 0 to N-1 for each number query 'select * from tab limit 1 offset ?' with '?' bound to selected number end transaction;
2018-06-01 2:12 GMT+02:00, Torsten Curdt <tcu...@vafer.org>: > I need to get some random rows from a large(ish) table. > > The following seems to be the most straight forward - but not the fastest. > > SELECT * FROM table ORDER BY random() limit 200 > > Is there a faster/better approach? > > cheers, > Torsten > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users