Re: query against large table not using sensible index to find very small amount of data

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: query against large table not using sensible index to find very small amount of data
Дата
Msg-id 23514.1396965338@sss.pgh.pa.us
обсуждение исходный текст
Ответ на query against large table not using sensible index to find very small amount of data  ("Andrew W. Gibbs" <awgibbs@awgibbs.com>)
Ответы Re: query against large table not using sensible index to find very small amount of data
Список pgsql-performance
"Andrew W. Gibbs" <awgibbs@awgibbs.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


В списке pgsql-performance по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: performance drop when function argument is evaluated in WHERE clause
Следующее
От: Shaun Thomas
Дата:
Сообщение: Re: PGSQL, checkpoints, and file system syncs