X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CCDA1D1B1AB for ; Mon, 21 Jun 2004 07:35:17 -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 28496-09 for ; Mon, 21 Jun 2004 10:35:11 +0000 (GMT) Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net [194.217.242.92]) by svr1.postgresql.org (Postfix) with ESMTP id BAFA6D1B170 for ; Mon, 21 Jun 2004 07:35:07 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-34.mail.demon.net with esmtp (Exim 3.35 #1) id 1BcM8D-000IGk-0Y; Mon, 21 Jun 2004 11:34:30 +0100 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id D477F16987; Mon, 21 Jun 2004 11:34:28 +0100 (BST) Message-ID: <40D6B9B4.4000209@archonet.com> Date: Mon, 21 Jun 2004 11:34:28 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Thanks Cc: pgsql-performance@postgresql.org Subject: Re: pg_fetch_array References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/213 X-Sequence-Number: 7271 Thanks wrote: > Hello.... > > I would like to know the performance of pg_fetch_array. Cosider the code: > > $query = "select * from foo"; > $result = pg_query( $db, $query ); > > while ($row = pg_fetch_array($result)) > { > $a = $row["a"]; > $b = $row["b"]; > $c = $row["c"]; > $d = $row["d"]; > } > > Does php need to read database everytime when pg_fetch_array is executed in > the while loop or all the rows have been in the memory after pg_query? Not knowing anything in detail about the PHP drivers, I'm almost certain that all rows are returned to PHP and then pg_fetch_array() reads that from memory. > If read database is needed, is there any method to copy all the rows into > memory by using other command? (because I have a application which needs > large amount database update/retrieval and I wish the performance of the > overall applications run faster.) > > or other method you would like to recommend in order to make the faster > response time? Are you sure that pg_fetch_array() is the problem? Can you give an example of what you're trying to do with the data? PS - there's a PHP list too. -- Richard Huxton Archonet Ltd