X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 500445285C for ; Wed, 6 Jul 2005 19:50:58 -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 01571-02 for ; Wed, 6 Jul 2005 22:50:49 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 2B053529A1 for ; Wed, 6 Jul 2005 19:50:48 -0300 (ADT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.20]) by yass.opencloud.co.nz with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1DqIjD-0001df-6f; Thu, 07 Jul 2005 10:50:51 +1200 Message-ID: <42CC604A.9050604@opencloud.com> Date: Thu, 07 Jul 2005 10:50:50 +1200 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Maik Wiege Cc: pgsql-jdbc@postgresql.org Subject: Re: get row count from a "cursor resultset" References: <42CC2EB6.8020505@gmx.de> <42CC5ACE.5070200@opencloud.com> <42CC5C41.90306@opencloud.com> In-Reply-To: <42CC5C41.90306@opencloud.com> X-Enigmail-Version: 0.90.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200507/35 X-Sequence-Number: 13183 Oliver Jowett wrote: > Oliver Jowett wrote: > >>Maik Wiege wrote: >> >> >>>I didn't find a solution for this, but there must be, because the pgAdmin III - tool does this. After starting the query in the SQL-Dialog it asks wether to retrieve just the first 100 results or all results displaying the corect amount of found rows. Or is this just not possible with jdbc. >> >> >>I'd point out that this does not require knowing exactly how many rows >>there are -- only that there are more than 100. You can do the >>equivalent in JDBC easily by setting fetchsize to 100 or so and calling >>next() 100 times.. if you haven't hit the end of the resultset by that >>point, it has more than 100 rows. > > > Oh, sorry, my mistake -- I misread your description. Perhaps they are > using either COUNT(*) in the same query or MOVE to get the number of rows. Ok, some digging in pgAdmin's svn web interface seems to indicate that pgadmin is not actually doing anything special here -- it does the full query via libpq's PQexec(), retrieving all the tuples (and hence can count them) but only does the work to construct a user interface displaying them all after that "lots of rows, retrieve anyway?" dialog has been answered. You could check this by looking at pgadmin's memory footprint while retrieving a big resultset. -O