0

I run this query 5 times, 5 seconds apart, on a table of 500,000 rows:

SELECT * FROM `apps` WHERE dev_name = '' ORDER BY RAND() LIMIT 10;

I'd like to get 50 rows that have a 90-95% chance of being unique. The query takes 10 seconds right now. I'd rather get it lower and have a smaller chance of being random.

User
  • 23,729
  • 38
  • 124
  • 207

2 Answers2

0

Try

AND RAND() >= 0.90

(or 0.95 if you like) in your WHERE clause.

user207421
  • 305,947
  • 44
  • 307
  • 483
0

You may want to study Fetching Random Rows from a Table, as highlighted in here in a related question. Another great article can be found here.

Community
  • 1
  • 1
luksch
  • 11,497
  • 6
  • 38
  • 53