Bug #76565 [NEW]: Very slow DB queries

From: Date: Mon, 02 Jul 2018 19:06:54 +0000
Subject: Bug #76565 [NEW]: Very slow DB queries
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216080@lists.php.net to get a copy of this message
From: gilperon at gmail dot com Operating system: CENTOS 7 PHP version: 7.2.7 Package: MySQL related Bug Type: Bug Bug description:Very slow DB queries Description: ------------ 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"). BUT for some strange reason doing DB queries is AT LEAST 2X slower - at least. I booted 2 CENTOS (version 7.1) servers - identical. Then on one I installed PHP 5.4.16 and in the other I installed PHP 7.2.7 (both were running the latest version of MariaDB). Then I created a simple database and executed the benchmarking in the TEST SCRIPT section. I executed this code at least 5 times on each server, allowing some delay between tests. They were very clear: PHP 7.2 took about 4.5 seconds to run PHP 5.4.16 took about 1.1 seconds to run So what? Is there something with PHP 7.2 that I am not aware that I should be taking into account when querying db? Test script: --------------- <?php include("connect.php"); $microtime = microtime(true); for ($i=0;$i<100;$i++) { $query = "SELECT * FROM table WHERE id = 'xxx'"; $result = mysqli_query($connection,$query); $data = mysqli_fetch_array($result); } echo microtime(true) - $microtime; ?> Expected result: ---------------- It should run AT LEAST at the same speed as PHP 5.4.16 Actual result: -------------- It runs at least twice or 3 times as slow. -- Edit bug report at https://bugs.php.net/bug.php?id=76565&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76565&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76565&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76565&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=76565&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=76565&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=76565&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=76565&r=needscript Try newer version: https://bugs.php.net/fix.php?id=76565&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=76565&r=support Expected behavior: https://bugs.php.net/fix.php?id=76565&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=76565&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=76565&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=76565&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76565&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=76565&r=dst IIS Stability: https://bugs.php.net/fix.php?id=76565&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=76565&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=76565&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=76565&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=76565&r=mysqlcfg

« previous php.bugs (#216080) next »