Monday, 15 February 2010

mysql - Select one or multiple random SQL rows with a WHERE condition on a large table -



mysql - Select one or multiple random SQL rows with a WHERE condition on a large table -

i've read http://explainextended.com/2009/03/01/selecting-random-rows/ suggested reply other questions selecting random row big table.

however, wonder how technique can combined selecting rows have field set value.

for case, i'm tyring build markov chain. table has id column auto-increment primary index. has snippet column, stores new part of string added, if prev_snippet column correct.

this means want select random row table has prev_snippet set string have. how can so, efficiently?

so yes, if dont care random, thought in linked post, pretty good. long index on prev_snippet column!

but because still indepentat utilize of random, end getting no row in result, though there one. ie each time filter runs, happens exclude.

franky, seek using order rand() limit 1, work pretty well. size of resultset important, not initial table size.

mysql random markov-chains

No comments:

Post a Comment