Re: Re: [PATCH] Caching for stable expressions with constant arguments v3 - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Re: [PATCH] Caching for stable expressions with constant arguments v3
Date
Msg-id 28529.1323101811@sss.pgh.pa.us
Whole thread Raw
In response to Re: [PATCH] Caching for stable expressions with constant arguments v3  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
List pgsql-hackers
Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:
> I wonder if it would be better to add the CacheExpr nodes to the tree as 
> a separate pass, instead of shoehorning it into eval_const_expressions? 
> I think would be more readable that way, even though a separate pass 
> would be more expensive.

A separate pass would be very considerably more expensive, because
(1) it would require making a whole new copy of each expression tree,
and (2) it would require looking up the volatility status of each
function and operator.  eval_const_expressions already has to do the
latter, or has to do it in a lot of cases anyway, so I think it's
probably the best place to add this.  If it weren't for (2) I would
suggest adding the work to setrefs.c instead, but as it is I think
we'd better suck it up and deal with any fallout in the later stages
of the planner.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: cannot read pg_class without having selected a database / is this a bug?
Next
From: "Kevin Grittner"
Date:
Subject: Re: [REVIEW] Patch for cursor calling with named parameters