X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2D5533A4392 for ; Mon, 15 Nov 2004 14:25:01 +0000 (GMT) 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 19574-08 for ; Mon, 15 Nov 2004 14:24:52 +0000 (GMT) Received: from smtp-vbr8.xs4all.nl (smtp-vbr8.xs4all.nl [194.109.24.28]) by svr1.postgresql.org (Postfix) with ESMTP id 564263A437D for ; Mon, 15 Nov 2004 14:24:53 +0000 (GMT) Received: from xs2.xs4all.nl (xs2.xs4all.nl [194.109.21.3]) by smtp-vbr8.xs4all.nl (8.12.11/8.12.11) with ESMTP id iAFEOrMh024220; Mon, 15 Nov 2004 15:24:53 +0100 (CET) (envelope-from jtv@xs4all.nl) Received: from xs2.xs4all.nl (jtv@localhost [127.0.0.1]) by xs2.xs4all.nl (8.12.11/8.12.11) with ESMTP id iAFEOrKR002684; Mon, 15 Nov 2004 15:24:53 +0100 (CET) (envelope-from jtv@xs4all.nl) Received: (from jtv@localhost) by xs2.xs4all.nl (8.12.11/8.12.11/Submit) id iAFEOrxX002681; Mon, 15 Nov 2004 15:24:53 +0100 (CET) (envelope-from jtv) Date: Mon, 15 Nov 2004 15:24:52 +0100 From: "Jeroen T. Vermeulen" To: jing han Cc: pgsql-interfaces@postgresql.org Subject: Re: about libpq-C FETCH ALL performance issue Message-ID: <20041115142452.GF90696@xs4all.nl> Mail-Followup-To: jing han , pgsql-interfaces@postgresql.org References: <20041115135501.51510.qmail@web53507.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20041115135501.51510.qmail@web53507.mail.yahoo.com> User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: by XS4ALL Virus Scanner 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: 200411/31 X-Sequence-Number: 5157 On Mon, Nov 15, 2004 at 05:55:01AM -0800, jing han wrote: > and then res = PQexec(conn, "FETCH ALL in myportal"); > > to get the data. > > I found when our database has more and more data, res > = PQexec(conn, "FETCH ALL in myportal"); cost more and > more time, much more than If you use just the FETCH ALL, why are you using a cursor in the first place? > Then I try FETCH 1 instead of FETCH ALL, no > improvement. Are you doing just one FETCH 1 to obtain a single row, or are you doing the FETCH 1 in a loop so you get all rows? The latter would be extremely slow in any case... Try fetching smaller blocks, like maybe 100 rows at a time, and see if that helps. > I wonder if there is other faster way ( I mean other > than FETCH ALL command) to get data from database with > libpq-C, or If you have a patch to make FETCH work > faster or new release to work better? Just do a normal "SELECT" without the cursor. This will give you all the data at once, just like a FETCH ALL. Jeroen