Re: 3-table query optimization

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: 3-table query optimization
Дата
Msg-id 20060810155017.GI23053@alvh.no-ip.org
обсуждение исходный текст
Ответ на Re: 3-table query optimization  (Michal Taborsky - Internet Mall <michal.taborsky@mall.cz>)
Список pgsql-performance
Michal Taborsky - Internet Mall wrote:
> Tom Lane napsal(a):
> >Michal Taborsky - Internet Mall <michal.taborsky@mall.cz> writes:
> >>SELECT product.product_id
> >>   FROM action
> >>   JOIN product ON (product.product_id=action.product_id)
> >>  WHERE action.shop_group_id=1
> >>    AND EXISTS (SELECT 1
> >>          FROM catalog.product_program
> >>          WHERE product_id=product.product_id
> >>            AND product_program.program_id =1104322
> >>    )
> >
> >Try converting the EXISTS subquery to an IN.
>
> The performance is roughly the same.

That's strange -- IN is usually much more amenable to better plans than
EXISTS.  Please post an EXPLAIN ANALYZE of the queries to see what's
going on.  It may be that the query is bound to be "slow" for some
cases (depending on the program_id I guess?)

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

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

Предыдущее
От: "Steve Poe"
Дата:
Сообщение: Re: Postgresql Performance on an HP DL385 and
Следующее
От: "Jim Nasby"
Дата:
Сообщение: Re: [BUGS] BUG #2567: High IOWAIT