title: how to speed up Mysql and PHP?
body: <p>I am developing a script in my localhst using PHP and mysql and I am dealing with large data (about 2 millions of records for scintific research)</p>
  
  <p>some queries I need to call once in a life (to analyse the data and prepare some data); however it takes very long time for example: now my script is analysing some data for more than 4 hours</p>
  
  <p>I knew I might have some problems in the optimization of my database I am not an expert</p>
  
  <p>for example I just figured out that "indexing" can be useful to speed up the queries
  however even with indexing some columns my script is still very slow</p>
  
  <p>any idea how to speed up my script (in PHP and mysql)</p>
  
  <p>I am using XAMPP as a server package</p>
  
  <p>Thanks a lot for help</p>
  
  <p>best regards</p>
  
  <p>update 1:</p>
  
  <h2>part of my slow script which takes more than 4 hours to process</h2>
  
  <pre><code>$sql = "select * from urls";//10,000 record of cached HTML documents
  $result = $DB-&gt;query($sql);
  while($row = $DB-&gt;fetch_array($result)){
  $url_id = $row["id"];
  $content = $row["content"];
  
  $dom = new DOMDocument();
  @$dom-&gt;loadHTML($content);
  $xpath = new DOMXPath($dom);
  $row = $xpath-&gt;evaluate("/html/body//a");
  
  for($i = 0; $i &lt; $row-&gt;length; $i++) {
       // lots of the code here to deal with the HTML documents and some update and insert and select queries which query another table which has 1 million record
  }
  </code></pre>
  
  <hr>
  
  <p>update 2:</p>
  
  <p>I do not have "JOIN" in my quires or even "IN" </p>
  
  <p>they are very simple queries</p>
  
  <p>and don't know! and I don't know how to know which causes the slowness? </p>
  
  <p>is it the PHP or the MYSQL?</p>