Re: selects with large offset really slow - Mailing list pgsql-general

From John Smith
Subject Re: selects with large offset really slow
Date
Msg-id 20030207221902.48287.qmail@web40711.mail.yahoo.com
Whole thread Raw
In response to Re: selects with large offset really slow  (Richard Huxton <dev@archonet.com>)
List pgsql-general

  Richard Huxton <dev@archonet.com> wrote:

> explain analyze select l.id, l.url
> from links l
> inner join stats s
> on l.id = s.link_id
> and s.referrer_id = 1
> order by l.url
> limit 100
> offset 90000;

There are three options you might want to look at:

1. Use a temporary table, then select from that for each page.
2. Use a cursor, and just fetch 100 records at a time from it.
3. Cheat and fetch where l.url>=X, remembering X as the highest url from the
last set of results. This of course means pages of results will overlap.

I tried 1 & 2 - both take about the same about of time as the original query :(. How do people deal with paging results from large tables? As is, web site pages take around 30 seconds to load (often timing out).

John



Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now

pgsql-general by date:

Previous
From: Edmund Dengler
Date:
Subject: Soft Updates/FFS and Postgresql
Next
From: wsheldah@lexmark.com
Date:
Subject: Re: selects with large offset really slow