Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: Help optimize view



> From: Kevin Grittner [mailto:Kevin(dot)Grittner(at)wicourts(dot)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



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group