title: When querying large data sets, prevent script timeout
body: <p>I have the following code:</p>
  
  <pre><code>$query = mysql_query("SELECT * FROM mytable");
  
  while($row = mysql_fetch_assoc($query)){
      mysql_query("INSERT INTO mytable2 (col1, col2) 
                   VALUES ('".$row['val1']."', '".$row['val2']."')");
  }
  </code></pre>
  
  <p>Understandably, the script times out at about 150,000 queries... outside of increasing the script memory what's the best way to prevent timeouts?</p>