Michal Taborsky - Internet Mall wrote:
> Tom Lane napsal(a):
> >Michal Taborsky - Internet Mall <[EMAIL PROTECTED]> 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.

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

Reply via email to