Re: Can this query go faster???

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Csaba Nagy <nagy(at)ecircle-ag(dot)com>
Cc: Joost Kraaijeveld <J(dot)Kraaijeveld(at)Askesis(dot)nl>, Pgsql-Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Can this query go faster???
Date: 2005-12-06 20:50:48
Message-ID: 20051206205048.GB22168@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Tue, Dec 06, 2005 at 10:52:57 +0100,
Csaba Nagy <nagy(at)ecircle-ag(dot)com> wrote:
> Joost,
>
> Why do you use an offset here ? I guess you're traversing the table
> somehow, in this case it would be better to remember the last zipcode +
> housenumber and put an additional condition to get the next bigger than
> the last one you've got... that would go for the index on
> zipcode+housenumber and be very fast. The big offset forces postgres to
> traverse that many entries until it's able to pick the one row for the
> result...

The other problem with saving an offset, is unless the data isn't changing
or you are doing all of the searches in one serialized transaction, the
fixed offset might not put you back where you left off.
Using the last key, instead of counting records is normally a better way
to do this.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Brandon Metcalf 2005-12-06 21:01:02 Context switching and Xeon processors
Previous Message Alan Stange 2005-12-06 20:48:20 Re: postgresql performance tuning