Bug #72736 [Opn->Ver]: Slow performance when fetching large dataset with mysqli / PDO

From: Date: Sat, 06 Aug 2016 15:32:26 +0000
Subject: Bug #72736 [Opn->Ver]: Slow performance when fetching large dataset with mysqli / PDO
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203001@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72736&edit=1 ID: 72736 Updated by: nikic@php.net Reported by: petr dot hrabal at gmail dot com Summary: Slow performance when fetching large dataset with mysqli / PDO -Status: Open +Status: Verified Type: Bug Package: *Database Functions Operating System: Debian 8 PHP Version: 7.0.9, 7.1.0-dev Block user comment: N Private report: N New Comment: Can confirm this is the case. Some further observations: * In PHP 7 the time increases quadratically with the number of rows. In PHP 5 it increases linearly. * PHP 7 goes back to reasonable performance with USE_ZEND_ALLOC=0 * callgrind with --cache-sim suggests that we're seeing a crazy number of LL data read misses in zend_mm_alloc_pages (this line: https://github.com/php/php-src/blob/master/Zend/zend_alloc.c#L856) This being callgrind, I don't know whether this is true My wild guess: We're going through the list of chunks where the first N are all full until we hit one which isn't. At each chunk we experience an LL miss due to aligned address conflicts. Previous Comments: ------------------------------------------------------------------------ [2016-08-02 16:10:49] petr dot hrabal at gmail dot com Expected resaul is that performance should be at least comparable and not dramaticaly worse ------------------------------------------------------------------------ [2016-08-02 14:55:57] petr dot hrabal at gmail dot com Description: ------------ I have large MySQL query (1.8M rows, 25 columns - all string between 20 and 256 chars) and I need to make 2 dimensional array from it (memory table based on primary key). Code works as expected, but $table creation takes a long time in PHP7.0.9 or 7.1.0-dev same proble apears when PDO is used more extensive info/diagnostics at http://stackoverflow.com/questions/38614982/mysqli-fetch-assoc-performance-php5-4-vs-php7-0 with tested dataset PHP5.x performs 10 times faster Test script: --------------- $vysledek = mysqli_query ( $conn,"SELECT * FROM table WHERE 1"); while($zaznam = mysqli_fetch_assoc ( $vysledek )){ $table[$zaznam['prikey']] = $zaznam; } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72736&edit=1

« previous php.bugs (#203001) next »