Hello!
I'm just switching to mysqlnd to be able to use
http://php.net/manual/en/book.mysqlnd-ms.php but I see some serious performance degradation compared to libmysql.
NewRewlic shows more 100ms spend in PHP after switching to mysqlnd
https://db.tt/68r9RfhJ
I've created a benchmark to reproduce to problem, it's quite simple:
$dbh = new PDO("mysql:host=$host; dbname=$dbname;", $user, $pass);
for ($i = 0; $i < 1000; $i++) {
$sth = $dbh->prepare("SELECT * FROM Orders LIMIT 100");
$sth->execute();
$result = $sth->fetchAll(PDO::FETCH_ASSOC);
}
Execution time:
libmysql - 2 seconds
mysqlnd - 3 seconds (50% more)
Can anybody explain me what's the reason behind it and how to solve it?
1. Slowness occurs for PDO mainly.
2. mysqli doesn't seem to be that much affected.
3. I cannot switch to mysqli due to usage of Doctrine.
4. Only way to catch up libmysql speedd is to enable `$dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false)` which I cannot do easily on production.
Thank you in advance for any help!
Best Regards,
Damian Tylczyński