Sure it is. Even with a limit, the engine has to generate a random number for every row in the table, then sort it, and THEN you can limit your results.
A better way when using PHP is to drop the ORDER BY and the LIMIT and instead, get the result set of the query into an array in php in the usual way then do:
$random_hotels=array_rand($hotels_list,5);
In [this thread here ](http://www.sitepoint.com/forums/mysql-182/speedy-order-rand-operation-727493.html)the efficiency of different methods of getting x number of random records is discussed.
Yeah, I’m mistaken. I still get lazy and use order by rand. If speed is a concern…
$db->queryAll("SELECT * FROM myTable WHERE id IN(".implode(',',array_slice(shuffle($this->quickQuery("SELECT id FROM myTable")), 0, 5).") LIMIT");
queryAll return an array of all results, quickQuery changes the return based on the result context - with a SQL statement that contains only one column it will return an array of that column.