> From: Kevin Grittner [mailto:Kevin.Grittner@xxxxxxxxxxxx] > > 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%'; The query I really want to run is several times larger than this. I didn't think people would want to wade through pages and pages worth of SQL and then explain analyze results - especially when I'm fairly certain that optimizing this smaller part of the overall aggregate query would provide me the help I was looking for. You're right about what I really want the query to evaluate to. I'll give your suggestion a try. Thanks. Mike ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your message can get through to the mailing list cleanly