From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Andrew W(dot) Gibbs" <awgibbs(at)awgibbs(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: query against large table not using sensible index to find very small amount of data |
Date: | 2014-04-08 13:55:38 |
Message-ID: | 23514.1396965338@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
"Andrew W. Gibbs" <awgibbs(at)awgibbs(dot)com> writes:
> A very common query against this table is of the form...
> SELECT * FROM events WHERE entity_type_id = XXX ORDER BY published_at DESC LIMIT 25;
> ... to get the most recent 25 events from the table for a given type
> of entity, and generally the query planner does the expected thing of
> using the two-part index on (entity_type_id, published_at). Every now
> and again, though, I have found the query planner deciding that it
> ought use the single column (published_at) index.
What is the estimated rows count according to EXPLAIN when it does that,
versus when it chooses the better plan?
> FWIW, we're running on 8.4.X and using the out-of-the-box
> default_statistics_target setting and haven't dabbled with setting
> table level statistics configurations.
8.4.X is due to reach EOL in July, so you really ought to be thinking
about an upgrade. It's not clear from the given info whether this issue
is fixable with stats configuration adjustments, is a bug already fixed
in later versions, or neither, but we're unlikely to make any significant
changes in the 8.4 planner code at this point...
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Shaun Thomas | 2014-04-08 14:00:05 | Re: PGSQL, checkpoints, and file system syncs |
Previous Message | Tom Lane | 2014-04-08 13:50:01 | Re: [PERFORM] performance drop when function argument is evaluated in WHERE clause |