php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50571 Performance Mysqli in php 5.3.1 signific slower than 5.2.6
Submitted: 2009-12-24 23:01 UTC Modified: 2010-01-09 19:19 UTC
From: millennium at qme dot nl Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5.3.1 OS: Windows Server 2003
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: millennium at qme dot nl
New email:
PHP Version: OS:

 

 [2009-12-24 23:01 UTC] millennium at qme dot nl
Description:
------------
The performance of Mysqli in php5.3.1(mysqlnd) is signific slower than 
the performance in php 5.2.6. (I know it's not the best code, but it's 
in production, and I would expect 5.3.1 is as fast as 5.2.6 or faster.

Reproduce code:
---------------
<?php
  $SERVER = "127.0.0.1";
  $USERNAME = "";
  $PASSWORD = "";
  $DATABASENAME = "";
  
  $high = 2000;
  $start = microtime(TRUE);
	for($i = 0; $i <$high; $i++)
	{
    $mysql = mysqli_connect($SERVER,$USERNAME,$PASSWORD,$DATABASENAME);
    mysqli_query($mysql, "UPDATE test SET title = '" . mysqli_real_escape_string($mysql,"test") . "' WHERE test_id = " . null);
    mysqli_close($mysql);
  }
  printf("time: %s secs, memory usage %s MiB.\n",
       number_format(microtime(TRUE) - $start, 2),
       number_format(memory_get_usage() / 1024 / 1024, 2));
?>

Expected result:
----------------
time: 1.83 secs, memory usage 0.15 MiB. (php 5.2.6)

Actual result:
--------------
time: 29.82 secs, memory usage 0.40 MiB

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-24 23:19 UTC] jani@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-12-24 23:26 UTC] millennium at qme dot nl
C:\php2>php sync.php
time: 28.37 secs, memory usage 0.40 MiB.

C:\php2>php -v
PHP 5.3.2-dev (cli) (built: Dec 22 2009 09:57:39)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
 [2009-12-25 00:25 UTC] scottmac@php.net
Can you adjust your test to see if its the connection, the query or the closing that's causing the problems?
 [2009-12-25 00:39 UTC] millennium at qme dot nl
If I move the connect and disconnect outside the loop, the speed is 
the (almost) the same.

php 5.2.6:
time: 0.27 secs, memory usage 0.15 MiB.
php 5.3.1:
time: 0.28 secs, memory usage 0.40 MiB.

moving the connect inside the loop again (keeping the disconnect 
outside)

php5.2.6:
time: 1.82 secs, memory usage 0.15 MiB.
php5.3.1:
time: 31.11 secs, memory usage 0.40 MiB.

So I guess it's the connect.
 [2009-12-25 00:41 UTC] pajoye@php.net
That's expected as mysqlnd uses php's stream. That brings a small overhead over raw sockets.
 [2010-01-09 19:19 UTC] jani@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 09:01:29 2024 UTC