Re: Aggregate View and Conditions taking FOREVER - Mailing list pgsql-general

From Tom Lane
Subject Re: Aggregate View and Conditions taking FOREVER
Date
Msg-id 27634.1192377528@sss.pgh.pa.us
Whole thread Raw
In response to Aggregate View and Conditions taking FOREVER  (illusina <illusina@hotmail.com>)
List pgsql-general
illusina <illusina@hotmail.com> writes:
> Ok..I've got a view which returns agency_id, fiscal_year, reporting_month,
> count_col0, count_col1...grouping by agency_id, fiscal_year and
> reporting_month. Now, if I just select * from myreport; it returns all the
> various counts for the various fiscal years and all that within 4 seconds,
> but if I add a conditional ie where fiscal_year = 2006 and reporting_month =
> 11, the query takes...10 minutes -- which I think is because the conditional
> cols (ie fiscal_year) is calculated via extract(year from datecol) which I
> think is causing that function to be checked on every row within the view.

Rather than guessing, how about showing EXPLAIN ANALYZE output for both
cases?

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Using C API
Next
From: Tom Lane
Date:
Subject: Re: drop table cascade doesn't drop manual sequences