Re: Help optimize view - Mailing list pgsql-performance

From Relyea, Mike
Subject Re: Help optimize view
Date
Msg-id 1806D1F73FCB7F439F2C842EE0627B1806666079@USA0300MS01.na.xerox.net
Whole thread Raw
In response to Re: Help optimize view  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
List pgsql-performance
> From: Kevin Grittner [mailto:Kevin.Grittner@wicourts.gov]
>
> 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

pgsql-performance by date:

Previous
From: "Andrew Hammond"
Date:
Subject: Re: [pgsql-jobs] Looking for database hosting
Next
From: "Campbell, Lance"
Date:
Subject: Terminology Question