speed w/ OFFSET/LIMIT

From: Damien <dm_mailings(at)abelia-decors(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: speed w/ OFFSET/LIMIT
Date: 2003-05-27 13:45:37
Message-ID: 200305271545.37533.dm_mailings@abelia-decors.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi !

I'm running a pretty simple select query on a pretty large table (70000
records). This table has some "flag" fields, each one textually explained by
another table ( flag VARCHAR(2), flag_details VARCHAR(60))

SELECT t.* , t1.flag1_details , ... , tn.flagn_details
FROM table t
NATURAL JOIN t1
NATURAL JOIN ...
NATURAL JOIN tn
ORDER BY main_field OFFSET x LIMIT 50

There is no where statement, this query is for display purposes on a web page.
My problem is, where OFFSET is low, execution takes only a few milli-seconds,
but where OFFSET is high (50 last results for example), execution can take 10
seconds...
Is there anything I can do to speed up such a query ?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Litvinov 2003-05-27 13:52:03 Re: Clustering using dblink
Previous Message Marc G. Fournier 2003-05-27 13:44:09 Re: [ANNOUNCE] PostgreSQL v7.3.3 Now Available for Download