Bug #76565 [Opn]: Very slow DB queries

From: Date: Tue, 03 Jul 2018 13:53:15 +0000
Subject: Bug #76565 [Opn]: Very slow DB queries
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216108@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76565&edit=1 ID: 76565 User updated by: gilperon at gmail dot com Reported by: gilperon at gmail dot com Summary: Very slow DB queries Status: Open Type: Bug Package: MySQL related Operating System: CENTOS 7 PHP Version: 7.2.7 Block user comment: N Private report: N New Comment: cmb@php.net I think my problem is similar to the one you referenced to. That other guys looks having the same problem as me BUT I am running a CENTOS 7 server (intead of linux). My Centos is 2GB RAM and 2vCPU (AMD EPYC). Previous Comments: ------------------------------------------------------------------------ [2018-07-03 11:44:48] cmb@php.net Is this a duplicate of bug #76442? ------------------------------------------------------------------------ [2018-07-03 09:09:57] celestinoxp at hotmail dot com I think you should show more details, like the mysql configuration file. In addition, the details of your system are also essential, cpu, ram. ------------------------------------------------------------------------ [2018-07-03 04:47:15] remi@php.net I cannot reproduce such difference. You seems to have some very big table / row, as I have to increase the loop to 10000 to have 1/2 second, on a small RHEL-7.5 VM PHP Version 5.4.16 en 0.55 (using php-mysql and libmysqlclient) PHP Version 5.4.16 en 0.65 (using php-mysqlnd) PHP Version 5.5.38 en 0.66 PHP Version 5.6.36 en 0.65 PHP Version 7.0.30 en 0,67 PHP Version 7.1.19 en 0,67 PHP Version 7.2.7 en 0,69 PHP Version 7.3.0alpha2 en 0.55 ------------------------------------------------------------------------ [2018-07-02 19:06:52] gilperon at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=76565&edit=1

« previous php.bugs (#216108) next »