Friday, 15 February 2013

sql - What to add to SELECT to output 10 RANDOM entries QUICKLY? -



sql - What to add to SELECT to output 10 RANDOM entries QUICKLY? -

how create

select w1.wort column1, w2.wort column2, w3.wort column3 woerter w1, woerter w2, woerter w3 w1.wort 'a%' , w2.wort 'm%' , w3.wort 'o%'

output 10 random entries quickly?

if want quick, order random() isn't going fast. perhaps speed things up:

select w1.wort column1, w2.wort column2, w3.wort column3 (select w1.* woerter w1 w1.wort 'a%' order random() limit 10) w1 cross bring together (select w2.* woerter w2 w2.wort 'm%' order random() limit 10) w2 cross bring together (select w3.* woerter w3 w3.wort 'o%' order random() limit 10) w3 order random() limit 10;

this limits final order by no more 1000 rows , prevents order by on total cartesian product.

sql sqlite sqlite3 android-sqlite

No comments:

Post a Comment