From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | Michal Taborsky - Internet Mall <michal(dot)taborsky(at)mall(dot)cz> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: 3-table query optimization |
Date: | 2006-08-10 15:50:17 |
Message-ID: | 20060810155017.GI23053@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Michal Taborsky - Internet Mall wrote:
> Tom Lane napsal(a):
> >Michal Taborsky - Internet Mall <michal(dot)taborsky(at)mall(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Jim Nasby | 2006-08-10 16:53:01 | Re: [BUGS] BUG #2567: High IOWAIT |
Previous Message | Steve Poe | 2006-08-10 15:47:05 | Re: Postgresql Performance on an HP DL385 and |