title: PHP MySQL running query in batches
body: <p>I am new to working with large amounts of data. I am wondering if there are any best practices when querying a database in batches or if anyone can give any advice.  </p>
  
  <p>I have a query that will pull out all data and PHP is used to  write the data to an XML file.   There can be anywhere between 10 and 500,000 rows of data and I have therefore witten the script to pull the data out in batches of 50, write to the file, then get the next 50 rows, append this to the file etc.  Is this OK or should I be doing something else?  Could I increase the batch size or should I decrease it to make the script run faster?</p>
  
  <p>Any advice would be much appreciated.</p>