Re: Question about speed: Weird Behavior

From: Samuel Gendler <sgendler(at)ideasculptor(dot)com>
To: Israel Ben Guilherme Fonseca <israel(dot)bgf(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Question about speed: Weird Behavior
Date: 2011-06-14 04:44:45
Message-ID: BANLkTim9igjkg9uctSWUBNOMJm9s6mUvbA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Mon, Jun 13, 2011 at 6:07 PM, Israel Ben Guilherme Fonseca <
israel(dot)bgf(at)gmail(dot)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

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Radosław Smogura 2011-06-14 08:15:05 Re: Question about speed: Weird Behavior
Previous Message Israel Ben Guilherme Fonseca 2011-06-14 01:07:32 Re: Question about speed: Weird Behavior