pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Samuel Gendler <sgendler@ideasculptor.com>
To: Israel Ben Guilherme Fonseca <israel.bgf@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Question about speed: Weird Behavior
Date: Mon, 13 Jun 2011 21:44:45 -0700
Message-ID: <BANLkTim9igjkg9uctSWUBNOMJm9s6mUvbA@mail.gmail.com> (raw)
In-Reply-To: <BANLkTi=HKOK1P0URDTidBuaqGJ2uptzT_w@mail.gmail.com>
References: <BANLkTimTaoOnVMcuUhnhE5VodRVDSTyH0w@mail.gmail.com>
	<4DF5B7B3.7010708@postnewspapers.com.au>
	<BANLkTimPigO8As72fj7MR59JU9GgzJSuyw@mail.gmail.com>
	<56264945a293522f5d499649330d3f84@mail.softperience.eu>
	<BANLkTiksRx=RvGtLqJgGv+PA4pHhOS_x4A@mail.gmail.com>
	<BANLkTimNhvPo9VeL94o0sxnBCDcRpLKK5A@mail.gmail.com>
	<BANLkTi=HKOK1P0URDTidBuaqGJ2uptzT_w@mail.gmail.com>

On Mon, Jun 13, 2011 at 6:07 PM, Israel Ben Guilherme Fonseca <
israel.bgf@gmail.com> wrote:

>
> When I use the count, my timings get around of
>
> 100 miliseconds.
>
> When I use the select it goes to
>
> 30 miliseconds.
>
>
I don't know much about the internals of the protocol used to move data
around for jdbc, but doesn't 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(*) can't 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

view thread (14+ messages)  latest in thread

Message-ID: <BANLkTim9igjkg9uctSWUBNOMJm9s6mUvbA@mail.gmail.com>
Permalink:  ../BANLkTim9igjkg9uctSWUBNOMJm9s6mUvbA@mail.gmail.com/
Also on:    postgresql.org/message-id/BANLkTim9igjkg9uctSWUBNOMJm9s6mUvbA@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: sgendler@ideasculptor.com, israel.bgf@gmail.com
  Subject: Re: Question about speed: Weird Behavior
  In-Reply-To: <BANLkTim9igjkg9uctSWUBNOMJm9s6mUvbA@mail.gmail.com>
  References: <BANLkTimTaoOnVMcuUhnhE5VodRVDSTyH0w@mail.gmail.com> <4DF5B7B3.7010708@postnewspapers.com.au> <BANLkTimPigO8As72fj7MR59JU9GgzJSuyw@mail.gmail.com> <56264945a293522f5d499649330d3f84@mail.softperience.eu> <BANLkTiksRx=RvGtLqJgGv+PA4pHhOS_x4A@mail.gmail.com> <BANLkTimNhvPo9VeL94o0sxnBCDcRpLKK5A@mail.gmail.com> <BANLkTi=HKOK1P0URDTidBuaqGJ2uptzT_w@mail.gmail.com> <BANLkTim9igjkg9uctSWUBNOMJm9s6mUvbA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox