Re: Help optimize view

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <pgsql-performance(at)postgresql(dot)org>, "Mike Relyea" <Mike(dot)Relyea(at)xerox(dot)com>
Subject: Re: Help optimize view
Date: 2007-08-13 20:02:15
Message-ID: 46C07277.EE98.0025.0@wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

>>> On Mon, Aug 13, 2007 at 1:48 PM, in message
<1806D1F73FCB7F439F2C842EE0627B18065F78DF(at)USA0300MS01(dot)na(dot)xerox(dot)net>, "Relyea,
Mike" <Mike(dot)Relyea(at)xerox(dot)com> wrote:
> I've increased shared_buffers to 128MB, and restarted the server. My
> total run time didn't really change.

Please forgive me if this guess doesn't help either, but could you try eliminating the GROUP BY options which don't echo values in the select value list, and move the HAVING conditions to a WHERE clause? Something like:

explain analyze
SELECT
"PrintSamples"."MachineID",
"PrintSamples"."PrintCopyID",
"tblColors"."ColorID",
avg("ParameterValues"."ParameterValue") AS "Mottle_NMF"
FROM "AnalysisModules"
JOIN
(
"tblColors"
JOIN
(
"tblTPNamesAndColors"
JOIN "PrintSamples"
ON ("tblTPNamesAndColors"."TestPatternName"::text = "PrintSamples"."TestPatternName"::text)
JOIN
(
"DigitalImages"
JOIN "PrintSampleAnalyses"
ON ("DigitalImages"."ImageID" = "PrintSampleAnalyses"."ImageID")
JOIN
(
"ParameterNames"
JOIN
(
"Measurements"
JOIN "ParameterValues"
ON "Measurements"."MeasurementID" = "ParameterValues"."MeasurementID"
) ON "ParameterNames"."ParameterID" = "ParameterValues"."ParameterID"
) ON "PrintSampleAnalyses"."psaID" = "Measurements"."psaID"
) ON "PrintSamples"."PrintSampleID" = "DigitalImages"."PrintSampleID"
) ON "tblColors"."ColorID" = "tblTPNamesAndColors"."ColorID"
) ON "AnalysisModules"."MetricID" = "Measurements"."MetricID"
WHERE "AnalysisModules"."AnalysisModuleName"::text = 'NMF'::text
AND "ParameterNames"."ParameterName"::text = 'NMF'::text
AND "PrintSamples"."TestPatternName"::text ~~ 'IQAF-TP8%'::text
AND "tblColors"."ColorID" <> 3
GROUP BY
"PrintSamples"."MachineID",
"PrintSamples"."PrintCopyID",
"tblColors"."ColorID"
;

I'd also be inclined to simplify the FROM clause by eliminating the parentheses and putting the ON conditions closer to where they are used, but that would be more for readability than any expectation that it would affect the plan.

-Kevin

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Philipp Specht 2007-08-13 20:12:33 Stable function optimisation
Previous Message Julius Stroffek 2007-08-13 19:49:56 Proposal: Pluggable Optimizer Interface