>>> On Fri, Aug 10, 2007 at 11:57 AM, in message
<1806D1F73FCB7F439F2C842EE0627B18065BEC18(at)usa0300ms01(dot)na(dot)xerox(dot)net>, "Relyea,
Mike" <Mike(dot)Relyea(at)xerox(dot)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