dimanche 26 août 2018

Fastest way of randomising result with large dataset in mysql

I want to return rows order by random from a table with large number of rows to be scanned

Tried:

1) select * from table order by rand() limit 1

2) select * from table where id in (select id from table order by rand() limit 1)

2 is faster than 1 but still too slow on table with large rowsmys




Aucun commentaire:

Enregistrer un commentaire