Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

mysqlnd slower to fetch all results than mysqli, solution?

9 views
Skip to first unread message

Damian Tylczyński

unread,
Jun 17, 2015, 6:18:11 AM6/17/15
to
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
0 new messages