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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 21:01:34 2025 UTC