Skip site navigation (1) Skip section navigation (2)

Re: [SQL] OFFSET impact on Performance???

From: Richard Huxton <dev(at)archonet(dot)com>
To: Andrei Bintintan <klodoma(at)ar-sd(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org, pgsql-performance(at)postgresql(dot)org
Subject: Re: [SQL] OFFSET impact on Performance???
Date: 2005-01-20 12:10:59
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performancepgsql-sql
Andrei Bintintan wrote:
> Hi to all,
> I have the following 2 examples. Now, regarding on the offset if it
> is small(10) or big(>50000) what is the impact on the performance of
> the query?? I noticed that if I return more data's(columns) or if I
> make more joins then the query runs even slower if the OFFSET is
> bigger. How can I somehow improve the performance on this?

There's really only one way to do an offset of 1000 and that's to fetch 
1000 rows and then some and discard the first 1000.

If you're using this to provide "pages" of results, could you use a cursor?

   Richard Huxton
   Archonet Ltd

In response to


pgsql-performance by date

Next:From: Merlin MoncureDate: 2005-01-20 13:20:21
Subject: Re: OFFSET impact on Performance???
Previous:From: Dan LangilleDate: 2005-01-20 11:56:20
Subject: Re: index scan of whole table, can't see why

pgsql-sql by date

Next:From: Andrei BintintanDate: 2005-01-20 13:45:47
Subject: Re: [SQL] OFFSET impact on Performance???
Previous:From: Andrei BintintanDate: 2005-01-20 11:13:44
Subject: OFFSET impact on Performance???

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group