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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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().