Re: Should changing offset in LIMIT change query plan (at all/so early)?

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <goran(dot)gugic(at)gmail(dot)com>,<pgsql-performance(at)postgresql(dot)org>
Subject: Re: Should changing offset in LIMIT change query plan (at all/so early)?
Date: 2010-11-21 15:44:21
Message-ID: 4CE8E9F70200002500037C8D@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

goran wrote:

> Trying to understand why query planer changes the plan from
> effective one to ineffective one when I change the offset in the
> LIMIT. Also, thankfully accepting RTFM pointers to the actual FMs.

The query planner will consider offset and limit clauses when
estimating the cost of each plan. The optimal plan will shift as
more tuples need to be read. If the plan is not shifting at the
right point, it probably means that you need to tune the costing
factors used by the planner.

You didn't report enough information for me to suggest any particular
change; if you follow up, please review the suggested information to
post:

http://wiki.postgresql.org/wiki/SlowQueryQuestions

In particular, information about the hardware and your
postgresql.conf settings would help.

You might also want to review this page and see if you can tune
things.

http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server

In particular, effective_cache_size, random_page_cost, and
seq_page_cost would be likely to need adjustment based on what you've
told us; however, it might pay to review the whole configuration.

-Kevin

Browse pgsql-performance by date

  From Date Subject
Next Message tv 2010-11-21 15:56:59 Re: Query Performance SQL Server vs. Postgresql
Previous Message tv 2010-11-21 15:42:07 Re: Query Performance SQL Server vs. Postgresql