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

From Marti Raudsepp
Subject Re: [PATCH] Caching for stable expressions with constant arguments v3
Date
Msg-id CABRT9RB7rdvke7JHg853fnJO42DyxagS0EuX1fojMfY7=tAxVA@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] Caching for stable expressions with constant arguments v3  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
Responses Re: [PATCH] Caching for stable expressions with constant arguments v3  (Marti Raudsepp <marti@juffo.org>)
List pgsql-hackers
On Mon, Dec 5, 2011 at 21:04, Heikki Linnakangas
<heikki.linnakangas@enterprisedb.com> wrote:
> Yet another idea would be to leave the CacheExprs there, but provide a way
> to reset the caches. PL/pgSQL could then reset the caches between every
> invocation. Or pass a flag to ExecInitExpr() to skip through the CacheExprs.

Great idea, I've ripped out all the conditional CacheExpr generation
logic from the planner and added a new boolean to CacheExprState
instead. This makes me happy as I'm now rid of most kludgy bits and
reduced the patch size somewhat. This also solves Tom's concern.

ExecInitExpr enables the cache when its 'PlanState *parent' attribute
isn't NULL. On the one hand this works out well since PlanState always
has a predictable life cycle thus caching is always safe.

On the other hand, a few places lose caching support this way since
they don't go through the planner:
* Column defaults in a COPY FROM operation. Common use case is
'timestamp default now()'
This might be a significant loss in some data-loading scenarios.
* ALTER TABLE t ALTER col TYPE x USING some_expr(); No big loss here.

Regards,
Marti

Attachment

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: ecmascript 5 DATESTYLE
Next
From: Robert Haas
Date:
Subject: Re: Inlining comparators as a performance optimisation