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 695EDD1B169 for ; Sun, 20 Jun 2004 17:02:29 -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 30942-08 for ; Sun, 20 Jun 2004 20:02:20 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id AF0BED1B1B7 for ; Sun, 20 Jun 2004 17:02:17 -0300 (ADT) Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) by tht.net (Postfix) with ESMTP id E09F876A7F; Sun, 20 Jun 2004 16:02:22 -0400 (EDT) Subject: Re: pg_fetch_array From: Rod Taylor To: Thanks Cc: Postgresql Performance In-Reply-To: References: Content-Type: text/plain Message-Id: <1087761736.64388.83.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Sun, 20 Jun 2004 16:02:17 -0400 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/211 X-Sequence-Number: 7269 > 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? You may need to ask the php people about this one. The PostgreSQL protocol would allow data to continue streaming in at the same time as you are processing other rows (asynchronous retrieval). So, optionally they may fetch and cache all rows in local memory at pg_query OR grab them in sets of 1000 rows and cache that (fetching the next set when the first set runs out) OR grab one row for each fetch. You could run a simple select that will fetch 100M rows from a table with no WHERE clause. See how quickly the first row come in, and how much memory is used by the process. I suspect they call all of the rows at pg_query execution. Otherwise they wouldn't know how to respond to a pg_num_rows() call. On a side note, that is a rather unique email address.