Re: Slow query postgres 8.3

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: Slow query postgres 8.3
Дата
Msg-id 4DA2ED2F020000250003C657@gw.wicourts.gov
обсуждение исходный текст
Ответ на Re: Slow query postgres 8.3  ("Anne Rosset" <arosset@collab.net>)
Ответы Re: Slow query postgres 8.3  (Claudio Freire <klaussfreire@gmail.com>)
Список pgsql-performance
"Anne Rosset" <arosset@collab.net> wrote:

>                            ->  Index Scan using role_oper_obj_oper
> on role_operation  (cost=0.00..93.20 rows=45 width=9) (actual
> time=0.236..71.291 rows=6108 loops=1)
>                                  Index Cond:
> (((object_type_id)::text = 'SfMain.Project'::text) AND
> ((operation_category)::text = 'admin'::text) AND
> ((operation_name)::text = 'admin'::text))

This looks like another case where there is a correlation among
multiple values used for selection.  The optimizer assumes, for
example, that category = 'admin' will be true no more often for rows
with operation_name = 'admin' than for other values of
operation_name.  There has been much talk lately about how to make
it smarter about that, but right now there's no general solution,
and workarounds can be tricky.

In more recent versions you could probably work around this with a
Common Table Expression (CTE) (using a WITH clause).  In 8.3 the
best idea which comes immediately to mind is to select from the
role_operation table into a temporary table using whichever of those
three criteria is most selective, and then join that temporary table
into the rest of the query.  Maybe someone else can think of
something better.

-Kevin

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

Предыдущее
От: Greg Smith
Дата:
Сообщение: Re: Multiple index builds on same table - in one sweep?
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: Multiple index builds on same table - in one sweep?