title: PHP 72 too slow on db queries
body: <p>IMPORTANT: I reported this terrible result of PHP 7.2 at <a href="https://bugs.php.net/bug.php?id=76565" rel="nofollow noreferrer">https://bugs.php.net/bug.php?id=76565</a> . I tried this with PHP 7.0.30 and also with PHP 7.1.13 and the problem is exactly the same: much much much slower queries in comparson with PHP 5.4.16.</p>
  
  <p>PHP 7.2 is very fast, amazingly fast. Doing very simple benchmarks (like looping thousands of times and doing some basic arithmetics) demonstrates that PHP 7.2 is easily 3x faster than PHP 5.4.16 (which is the default PHP version that comes enabled to be installed on Centos 7 using the "yum").</p>
  
  <p>BUT for some strange reason doing DB queries is AT LEAST 2X slower - at least.</p>
  
  <p>I booted 2 CENTOS servers - identical. Then on one I installed PHP 5.4.16 and in the other I installed PHP 7.2 (both were running the latest version of MariaDB).</p>
  
  <p>Then I created a simple database and executed the benchmarking below:</p>
  
  <pre><code>&lt;?php
  
  include("connect.php");
  
  $microtime = microtime(true);
  
  for ($i=0;$i&lt;100;$i++) {
  
      $query = "SELECT * FROM table WHERE id = 'xxx'";
      $result = mysqli_query($connection,$query);
      $data = mysqli_fetch_array($result);
  
  }
  
  echo microtime(true) - $microtime;
  
  ?&gt;
  </code></pre>
  
  <p>I executed this code at least 5 times on each server, allowing some delay between tests. They were very clear:</p>
  
  <p>PHP 7.2 took about 4.5 seconds to run
  PHP 5.4.16 took about 1.1 seconds to run</p>
  
  <p>So what? Is there something with PHP 7.2 that I am not aware that I should be taking into account when querying db? </p>
  
  <p>EDIT</p>
  
  <p>Replying some comments:</p>
  
  <p>1) to install PHP 5.4.16 I just did this:</p>
  
  <pre><code>yum install php php-mysql mariadb
  </code></pre>
  
  <p>2) to install PHP 7.2.7 I first installed REMI, then I did this:</p>
  
  <pre><code>yum install yum-utils
  yum-config-manager --enable remi-php72
  yum install php php-mysql mariadb
  </code></pre>
  
  <p>The connection to the DB is made with this code:</p>
  
  <pre><code>$connection = mysqli_connect("localhost","root","----");
  mysqli_select_db($connection ,"database");
  </code></pre>
  
  <p>I am aware of a bug regarding using "localhost", but I also tried "127.0.0.1" and the results were the same, so using "localhost" in this case does not change anything.</p>
  
  <p>I just checked right now, both servers have same CPU (double checked using <code>cat /proc/cpuinfo</code>) and same SSDs. Ram is the same and RAM consumption is very close when using the command <code>free</code>.</p>