Re: Premature view materialization in 8.2? - Mailing list pgsql-performance

From Tom Lane
Subject Re: Premature view materialization in 8.2?
Date
Msg-id 15902.1175884488@sss.pgh.pa.us
Whole thread Raw
In response to Re: Premature view materialization in 8.2?  ("Jonathan Ellis" <jonathan@utahpython.org>)
Responses Re: Premature view materialization in 8.2?
List pgsql-performance
"Jonathan Ellis" <jonathan@utahpython.org> writes:
> It was in my original post unless it got clipped:

Sorry, I had forgotten.

> The problem seems to be that clan_members_v contains a call to an
> expensive function:

I'll bet that the function is marked VOLATILE.  8.2 is more conservative
about optimizing away volatile functions than previous releases.  If
it has no side effects, mark it STABLE (or can it even be IMMUTABLE?).

In some quick testing, I verified that 8.2 does evaluate the function at
the join level corresponding to the view's join (and I think this is
preventing it from considering other join orders, too).  If you change
the function's marking to be nonvolatile then the function disappears
from the plan entirely, and also it seems to prefer joining "clans" sooner.

            regards, tom lane

pgsql-performance by date:

Previous
From: Michael Stone
Date:
Subject: Re: SCSI vs SATA
Next
From: Ron
Date:
Subject: Re: SCSI vs SATA