Re: Help optimize view

From: "Relyea, Mike" <Mike(dot)Relyea(at)xerox(dot)com>
To: <pgsql-performance(at)postgresql(dot)org>
Cc: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
Subject: Re: Help optimize view
Date: 2007-08-20 14:02:48
Message-ID: 1806D1F73FCB7F439F2C842EE0627B1806666079@USA0300MS01.na.xerox.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

> 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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Campbell, Lance 2007-08-20 14:36:00 Terminology Question
Previous Message Andrew Hammond 2007-08-20 00:37:07 Re: [pgsql-jobs] Looking for database hosting