Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

Php mysql shuffle output speed

1

45 views

Hello,

I have a mysql query that returns 20 results from a table of 110,000,000. I would like to shuffle these before echoing them out using php.

Is it faster to use

ORDER RAND()

or

shuffle the array in php somehow?

asked April 11, 2011 11:30 am CDT
posted via StackOverflow

1 Answer

1
Best answer
 

Depending on the amount of results you're pulling back from MySQL, ORDER BY RAND() will be faster.

If you're only returning 20 like you say, the performance differences will be negligible.

You could always test it out and see which is better for you, to shuffle an array in PHP you would use shuffle().

answered April 11, 2011 12:24 pm CDT

Your answer

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions
MySQL - "select" speed
January 15, 2011
MySQL Query to XML output
December 27, 2010