#50571 [Fbk]: Performance Mysqli in php 5.3.1 signific slower than 5.2.6
ID: 50571
Updated by: pajoye@php.net
Reported By: millennium at qme dot nl
Status: Feedback
Bug Type: MySQLi related
Operating System: Windows Server 2003
PHP Version: 5.3.1
New Comment:
That's expected as mysqlnd uses php's stream. That brings a small
overhead over raw sockets.
Previous Comments:
------------------------------------------------------------------------
[2009-12-25 00:39:23] 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:25:35] 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-24 23:26:32] 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-24 23:19:05] 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:01:39] 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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50571&edit=1
Thread (8 messages)