From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: pgsql-performance@postgresql.org
To: Mike Relyea <Mike.Relyea@xerox.com>
Subject: Re: Help optimize view
Date: Sat, 18 Aug 2007 20:01:50 -0500
Message-ID: <46C7502D.EE98.0025.0@wicourts.gov> (raw)
In-Reply-To: <1806D1F73FCB7F439F2C842EE0627B18065BEC18@usa0300ms01.na.xerox.net>
References: <1806D1F73FCB7F439F2C842EE0627B18065BEC18@usa0300ms01.na.xerox.net>
>>> On Fri, Aug 10, 2007 at 11:57 AM, in message
<1806D1F73FCB7F439F2C842EE0627B18065BEC18@usa0300ms01.na.xerox.net>, "Relyea,
Mike" <Mike.Relyea@xerox.com> wrote:
> I'm have the following view as part of a larger, aggregate query that is
> running slower than I'd like.
> . . .
> HAVING "PrintSamples"."MachineID" = 4741 OR "PrintSamples"."MachineID" =
> 4745 AND "AnalysisModules"."AnalysisModuleName" = 'NMF' AND
> "ParameterNames"."ParameterName" = 'NMF' AND "tblColors"."ColorID" <> 3
> AND "PrintSamples"."TestPatternName" LIKE 'IQAF-TP8%';
First off, let's make sure we're optimizing the query you really want to run.
AND binds tighter than OR, so as you have it written, it is the same as:
HAVING "PrintSamples"."MachineID" = 4741
OR ( "PrintSamples"."MachineID" = 4745
AND "AnalysisModules"."AnalysisModuleName" = 'NMF'
AND "ParameterNames"."ParameterName" = 'NMF'
AND "tblColors"."ColorID" <> 3
AND "PrintSamples"."TestPatternName" LIKE 'IQAF-TP8%';
)
I fear you may really want it evaluate to:
HAVING ("PrintSamples"."MachineID" = 4741 OR "PrintSamples"."MachineID" = 4745)
AND "AnalysisModules"."AnalysisModuleName" = 'NMF'
AND "ParameterNames"."ParameterName" = 'NMF'
AND "tblColors"."ColorID" <> 3
AND "PrintSamples"."TestPatternName" LIKE 'IQAF-TP8%';
-Kevin
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: Kevin.Grittner@wicourts.gov, Mike.Relyea@xerox.com
Subject: Re: Help optimize view
In-Reply-To: <46C7502D.EE98.0025.0@wicourts.gov>
* 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