Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 8D4FEB5D80A for ; Tue, 14 Jun 2011 05:25:55 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 03902-06 for ; Tue, 14 Jun 2011 08:25:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.softperience.eu (static-ip-217-118-26-141.inaddr.intergenia.de [217.118.26.141]) by mail.postgresql.org (Postfix) with ESMTP id 3355EB5D800 for ; Tue, 14 Jun 2011 05:25:49 -0300 (ADT) Received: from mail.softperience.eu (static-ip-217-118-26-141.inaddr.intergenia.de [217.118.26.141]) by mail.softperience.eu (Postfix) with ESMTPA id A1560C000C2; Tue, 14 Jun 2011 10:25:35 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Tue, 14 Jun 2011 10:25:35 +0200 From: =?UTF-8?Q?Rados=C5=82aw_Smogura?= To: Samuel Gendler Cc: Israel Ben Guilherme Fonseca , Subject: Re: Question about speed: Weird Behavior In-Reply-To: References: <4DF5B7B3.7010708@postnewspapers.com.au> <56264945a293522f5d499649330d3f84@mail.softperience.eu> Message-ID: <1d5c89dfd44bddbdce2eff4e2287f66e@mail.softperience.eu> X-Sender: rsmogura@softperience.eu User-Agent: Roundcube Webmail/0.5.1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201106/36 X-Sequence-Number: 21960 On Mon, 13 Jun 2011 21:44:45 -0700, Samuel Gendler wrote: > On Mon, Jun 13, 2011 at 6:07 PM, Israel Ben Guilherme Fonseca wrote: > >> When I use the count, my timings get around of >> >> 100 miliseconds. >> >> When I use the select it goes to >> >> 30 miliseconds. > > I dont know much about the internals of the protocol used to move > data > around for jdbc, but doesnt this actually make some sense?  If the > query returns as soon as the first row has arrived, then select * > should definitely be faster than select count(*), since count(*) cant > return until the entire table has been scanned, whereas select * > returns with the first row received.  That, at least, seems like a > likely candidate for the difference between them, no? > > --sam > > > > Links: > ------ > [1] mailto:israel.bgf@gmail.com Did you ran your queries in above order or did you changed order of queries. Please bear in mind, that if you set fetch size, then cursor approch will be used and not all data will be transferred to client side. Regards, Radek