php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43561 Selecting large numbers of rows results in OOM
Submitted: 2007-12-11 07:56 UTC Modified: 2010-05-31 21:35 UTC
From: php at seven dot net dot nz Assigned: ssufficool (profile)
Status: Closed Package: PDO related
PHP Version: 5.2.5 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php at seven dot net dot nz
New email:
PHP Version: OS:

 

 [2007-12-11 07:56 UTC] php at seven dot net dot nz
Description:
------------
Selecting a large number of rows in a prepared statement results in an OOM error after execute() is called.

The SQL server is located on a different box. I have not been able to pinpoint the exact number of rows as it is a moving target. It has failed on as low as 20k and as high as 50k.

Obviously it would result in OOM if I had selected everything into an array, but from what I gather results should not be being sent to PHP until the fetchXYZ functions are called. Or am I wrong?

It worked with 5.2.0 on the same box.

Reproduce code:
---------------
<?php
$database = new PDO (
 'dblib:host=10.9.8.213;dbname=realenz',
 'sa',
 'loo0nieP'
);

$query = "SELECT TOP 50000 * FROM nc_listing_full";

$statement = $database->prepare ($query);

$statement->execute ();
?>

Expected result:
----------------
Query to execute

Actual result:
--------------
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4 bytes) in /www/data/realestate-dev/scripts/htdocs/cron/rebuild_listings.php on line 12


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-11 16:06 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The driver maybe pre-allocating memory at the time of the fetch, hence 
the OOM.
 [2010-05-31 21:35 UTC] ssufficool@php.net
-Status: Bogus +Status: Closed -Assigned To: +Assigned To: ssufficool
 [2010-05-31 21:35 UTC] ssufficool@php.net
Fixed in revision 300002.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 11:01:28 2024 UTC