Re: plan question - query with order by and limit not choosing index depends on size of limit, table

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Mike Broers" <mbroers(at)gmail(dot)com>, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: plan question - query with order by and limit not choosing index depends on size of limit, table
Date: 2011-01-05 23:10:36
Message-ID: 4D24A60C020000250003901A@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Mike Broers <mbroers(at)gmail(dot)com> wrote:

> Hello performance, I need help explaining the performance of a
> particular query

You provided some of the information needed, but you should review
this page and post a bit more:

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

In particular, post the result of EXPLAIN ANALYZE, not just EXPLAIN.
Also, showing all overrides in your postgresql.conf file is
important, and some information about your hardware. How big is the
active portion of your database (the frequently read portion)?

> Why does the smaller limit cause it to skip the index?

Because the optimizer thinks the query will return rows sooner that
way.

> Is there a way to help the planner choose the better plan?

You might get there by adjusting your memory settings and/or costing
settings, but we need to see more information to know that.

-Kevin

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Josh Berkus 2011-01-06 18:58:59 Re: Wrong docs on wal_buffers?
Previous Message Pierre C 2011-01-05 22:58:32 Re: Wrong docs on wal_buffers?