Re: out of memory doing multiple inserts with DB_DataObject
| From: | Joe Stump | Date: | Fri, 13 Feb 2004 01:18:33 +0000 |
| Subject: | Re: out of memory doing multiple inserts with DB_DataObject | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-25637@lists.php.net to get a copy of this message | ||
It's could be because DB_DataObject caches every single resource from
each query in a global variable.
--Joe
On Thu, 2004-02-12 at 20:51, todd wrote:
> Hi,
> I've just started using DB_DataObject, and I'm trying to populate a
> table called "organization" with some dummy data. So I created a loop to
> insert 10000 rows. However, it's exceeding the 8MB memory limit on our
> server around the 4300th insert. Any idea why it's using so much memory?
>
> AccountId is a unique key in my organization table, but it is not the
> primary key. The primary key is auto incrementing (MySQL DB). Here is
> the sample code:
>
> DB_DataObject::DebugLevel(1);
>
> $org = new DataObject_ENOrganization();
> $orgCnt = $org->count();
> echo( "$orgCnt orgs <br>");
>
> for($i = 0; $i < 10000; $i++) {
> $org->setId(null);
> $org->setAccountId($orgCnt + $i);
> $rslt = $org->insert();
> }
>
> I also tried doing the inserts directly using PEAR:DB and it stays below
> the 8MB cap just fine.
> for($i = 0; $i < 10000; $i++) {
> $newAccountId = $orgCnt+$i;
> $db->query("INSERT INTO organization(accountId)
> VALUES($newAccountId)");
> print_r("$i");
> print_r("<BR>");
> }
>
> Thanks,
> Todd Wallar
--
--
Joe Stump, President
JCS Solutions
p. (734) 786 0176
f. (520) 844 9344
http://www.jcssolutions.com