Bug #55003 [Fbk->NoF]: PDO prepare() ignores MYSQL_ATTR_USE_BUFFERED_QUERY
| From: | php-bugs at lists dot php dot net | Date: | Mon, 18 Feb 2013 00:34:54 +0000 |
| Subject: | Bug #55003 [Fbk->NoF]: PDO prepare() ignores MYSQL_ATTR_USE_BUFFERED_QUERY | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-177007@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55003&edit=1
ID: 55003
Updated by: php-bugs@lists.php.net
Reported by: jamesvl+php at gmail dot com
Summary: PDO prepare() ignores MYSQL_ATTR_USE_BUFFERED_QUERY
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: PDO related
Operating System: all
PHP Version: 5.3.6
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2012-05-04 09:16:09] uw@php.net
Please try using this snapshot:
http://snaps.php.net/php5.4-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
------------------------------------------------------------------------
[2011-06-06 20:15:09] jamesvl+php at gmail dot com
Description:
------------
Steps to reproduce:
Set up a database so a query can return ~ 10,000 rows - enough to bump memory usage to noticeable
levels.
Use PDO to prepare a query where you explicitly disable buffered queries:
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false. The PHP docs give an example of how to do this at http://www.php.net/manual/en/ref.pdo-mysql.php.
Execute that statement.
Use "memory_get_peak_usage()" to watch PHP memory usage for the script before and after
the call to pdoStmt->execute().
Notes:
Settings PDO::MYSQL_ATTR_USE_BUFFERED_QUERY to false when creating the PDO object *does* work as
expected. (i.e. query buffering will be turned off or on; default is on if not specified)
However, the PHP documentation makes it appear that an individual prepared statement should be able
to change or override this settings for an individual query, which is not the case.
PHP version tested: PHP 5.3.6 using mysqlnd, Win32 and Linux custom compile.
Note that testing on PHP 5.2 (i.e. without mysqlnd) is not possible since mysqlib allocates memory
outside of the PHP parser, and thus is not tracked by memory_get_peak_usage() and is not limited by
php.ini memory_limit settings.
Test script:
---------------
if ($this->db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
$stmt = $this->db->prepare($qry,
array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false));
echo "\nmax bytes mem used: " . memory_get_peak_usage() . "\n";
$stmt->execute();
echo "max bytes mem used: " . memory_get_peak_usage() . "\n";
}
Expected result:
----------------
Expect to see:
Very little new memory allocated even when returning large result sets.
Memory usage should *not* vary based on the result set size.
ex:
max bytes mem used: 700624
max bytes mem used: 700624
Actual result:
--------------
Actually see:
Memory usage increases directly with the size of the result set returned - PDO is using a buffered
query.
ex:
max bytes mem used: 700240
max bytes mem used: 26291600
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55003&edit=1