Jump to content

Need faster alternative to RAND()


ableroos

Recommended Posts

I am combining 2 words out of a table with about 60,000 rows to create random names. I have used RAND() but it is way too slow.

 

Here is my code:

 

$sqlquery = "SELECT text FROM words ORDER BY RAND() LIMIT 2";

$results  = mysql_query($sqlquery);

  while ($row = mysql_fetch_array($results, MYSQL_NUM)) {

      echo strtoupper ($row[0] . " " . $row[1]);

  }

 

Can anyone suggest a faster alternative and show me an example?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/180769-need-faster-alternative-to-rand/
Share on other sites

The problem with the solutions on that page is all the selections end up pulling from the same region of the database so word 1 is always a word beginning with "A" and the second word is almost always word that begins with A as well or perhaps a "B". They are random, but not very random if that makes sense.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.