Re: 3-table query optimization

From: "Jim C(dot) Nasby" <jnasby(at)pervasive(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-15 15:08:35
Message-ID: 20060815150834.GP27928@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Thu, Aug 10, 2006 at 09:30:35AM +0200, 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. For some groups it's better, for
> some groups, the bigger ones, it's a bit worse. I forgot to mention,
> that the server is running 8.0.2. Upgrading would be a bit painful, as
> it is a 24/7 production system, but if it would help significantly, we'd
> give it a go.

You're exposing yourself to at least one data-loss bug and a security
hole by running 8.0.2. You should at least move to 8.0.8, which won't
require a lot of downtime.

If you can make it happen, moving to 8.1.4 would almost certainly net a
noticable performance gain. I've seen 50-100% improvements, but how much
gain you'll actually see is highly workload dependent.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Mark Lewis 2006-08-15 15:10:05 Re: Inner Join of the same table
Previous Message Jim C. Nasby 2006-08-15 15:05:30 Re: Beginner optimization questions, esp. regarding Tsearch2