From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org, "Andrea Olson" <Aolson.CCAP.Courts@wicourts.gov>
Cc: Bill Severson <BSEVERS.CCAP.Courts@wicourts.gov>
Cc: John Hutchins <jhutchi.CCAP.Courts@wicourts.gov>
Cc: Randy Peterson <RPETERS.CCAP.Courts@wicourts.gov>
Cc: Shannon Spranger <ssprang.CCAP.Courts@wicourts.gov>
Subject: Re: EXISTS optimization
Date: Fri, 23 Mar 2007 19:04:12 -0400
Message-ID: <26175.1174691052@sss.pgh.pa.us> (raw)
In-Reply-To: <46040DAC.EE98.0025.0@wicourts.gov>
References: <4603C1A3.EE98.0025.0@wicourts.gov>
<4603C1A3.EE98.0025.0@wicourts.gov>
<25339.1174686582@sss.pgh.pa.us>
<46040DAC.EE98.0025.0@wicourts.gov>
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> If you want that, try rewriting the EXISTS to an IN:
>>
>> AND ("H"."tranNo", "H"."countyNo") IN
>> (
>> SELECT "D"."tranNo", "D"."countyNo" FROM "TranDetail" "D"
>> WHERE "D"."caseNo" LIKE '2006TR%'
>> )
> That's the good news. The bad news is that I operate under a
> management portability dictate which doesn't currently allow that
> syntax, since not all of the products they want to cover support it.
Which part of it don't they like --- the multiple IN-comparisons?
> I tried something which seems equivalent, but it is running for a very
> long time.
> AND "H"."tranNo" IN
> (
> SELECT "D"."tranNo" FROM "TranDetail" "D"
> WHERE "D"."caseNo" LIKE '2006TR%'
> AND "D"."countyNo" = "H"."countyNo"
> )
No, that's not gonna accomplish a darn thing, because you've still got
a correlated subquery (ie, a reference to outer "H") and so turning the
IN into a join doesn't work.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, Kevin.Grittner@wicourts.gov, Aolson.CCAP.Courts@wicourts.gov, BSEVERS.CCAP.Courts@wicourts.gov, jhutchi.CCAP.Courts@wicourts.gov, RPETERS.CCAP.Courts@wicourts.gov, ssprang.CCAP.Courts@wicourts.gov
Subject: Re: EXISTS optimization
In-Reply-To: <26175.1174691052@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox