title: Is is better to randomize result using MySQL or PHP?
body: <p>Is it better to return random rows using MySQL or PHP commands?  </p>
  
  <p>For example, I have a <code>product</code> table with 10 columns and 1000000 rows and want to return 10 random rows from it.</p>
  
  <ul>
  <li><p>Method 1 (let MySQL do most of the work):</p>
  
  <pre><code>$query = mysql_query("SELECT * FROM product WHERE product_id in (SELECT product_id FROM product ORDER BY RAND() LIMIT 10)");
  while($results[] = mysql_fetch_row($query));
  </code></pre></li>
  <li><p>Method 2 (let PHP do most of the work):</p>
  
  <pre><code>$query = mysql_query("SELECT * FROM product");
  while($results[] = mysql_fetch_row($query));
  shuffle($results);
  $results = array_slice($results, 0, 10);
  </code></pre></li>
  </ul>
  
  <p>Is method 1 or method 2 better?</p>