I'm finally switching to mysqli.
However I have spotted a significant performance difference.
I have a script which makes about 25.000 queries. The Script takes 15 seconds with mysqli and mysqlnd as driver And 10 seconds with MySQL and the old MySQL client library.
The raw SQL time is 7.7 seconds on both scenarios.
It has to be the connection time between PHP and MySQL that names the difference.
Is mysqli slower than the old mysql?
I have located the performance difference in the connection process.
I log the time in these to scripts. And the time difference is about 4 seconds
function connect() {
$time_start = $this->microtime_float();
$this->link = mysql_connect($GLOBALS['DB_HOST'], $GLOBALS['DB_USER'], $GLOBALS['DB_PASS'])
or die ("Could not connect to DB\n");
mysql_select_db($GLOBALS['DB_NAME'])
or die("Could not select ".$GLOBALS['DB_NAME']."\n");
$time_end = $this->microtime_float();
$_SESSION["MySQLTimeConnection"] += ($time_end - $time_start);
}
function connect() {
$time_start = $this->microtime_float();
$this->link = mysqli_connect($GLOBALS['DB_HOST'], $GLOBALS['DB_USER'], $GLOBALS['DB_PASS'],$GLOBALS['DB_NAME'])
or die ("Kunne ikke få forbindelse til databasen ".$GLOBALS['DB_NAME']."\n");
$time_end = $this->microtime_float();
$_SESSION["MySQLTimeConnection"] += ($time_end - $time_start);
}