X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 44343D1B1AE for ; Wed, 2 Jun 2004 17:41:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50893-03 for ; Wed, 2 Jun 2004 20:41:36 +0000 (GMT) Received: from smtp104.mail.sc5.yahoo.com (smtp104.mail.sc5.yahoo.com [66.163.169.223]) by svr1.postgresql.org (Postfix) with SMTP id 1FA35D1B196 for ; Wed, 2 Jun 2004 17:41:32 -0300 (ADT) Received: from unknown (HELO AERS04) (adampalmblad@142.104.12.41 with login) by smtp104.mail.sc5.yahoo.com with SMTP; 2 Jun 2004 20:41:33 -0000 Message-ID: <007a01c448e1$fde018a0$97019696@AERS04> From: "A Palmblad" To: "Robby Russell" Cc: References: <005501c44755$5a851580$97019696@AERS04> <40BE35EF.8030003@commandprompt.com> Subject: Re: PHP memory usage Date: Wed, 2 Jun 2004 13:41:33 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200406/3 X-Sequence-Number: 2777 I watch Postgres while its doing the query - and the postmaster is not the culprit for memory usage. It looks to me like PHP's postgres driver is loading the entire result into memory when I do a query. That is, the postgres process stays within the memory its config tells it to use, while a PHP script will eat as much as it can to load the result set. Although I would think best practices would dictate the use of a cursor or some limit statements, I was also trying to get at whether or not a PHP extension should be able to use as much RAM as it wants. -Adam ----- Original Message ----- From: "Robby Russell" To: "A Palmblad" Cc: Sent: Wednesday, June 02, 2004 1:17 PM Subject: Re: [PHP] PHP memory usage > A Palmblad typed this on 05/31/2004 02:22 PM: > > We've been running into some issues with PHP and Postgres, and memory usage. > > On a dual athlon 64, w/ 4 gigs of RAM, PHP 4.3.6, and Postgres 7.4.2 I've > > seen our server start to crawl after some queries returning very large > > result sets. Although large result sets aren't exactly what we want to be > > dealing with, I really want to avoid a situation where a user could disrupt > > our server with certain options to some searches. > > > > I did a quick commandline test, and it looks like PHP starts to eat memory > > during its call to pg_query. By eat memory, I mean use memory well in > > excess of php.ini's memory_limit of 8 megs. (I stop it around 90% of > > available memory usage) Is this acceptable behaviour, or should I report it > > to PHP as a bug? If not, are my only solutions to wrap my selects in > > cursors and/or to use limit? > > > > -Adam Palmblad > > > > I am going to take a quick guess and suggest that test those queries in > psql itself. You might be running into some issues with your queries. > > > Test your queries with psql, EXPLAIN. > \h EXPLAIN > > -Robby > > -- > Robby Russell, | Sr. Administrator / Lead Programmer > Command Prompt, Inc. | http://www.commandprompt.com > rrussell@commandprompt.com | Telephone: (503) 667.4564 > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings