Bruno Wolff III <bruno(at)wolff(dot)to> writes:
> I was naively expecting that the planner would notice the common
> subexpressions and only compute them once.
There isn't currently any code for detection of common subexpressions of
My gut feeling is that searching for common subexpressions would be a
net waste of cycles in the vast majority of queries. It'd be fairly
expensive (a naive implementation would be roughly O(N^2) in the number
of expression nodes), with zero payback in very many cases.
It might be worth doing for very constrained classes of subexpressions.
For instance, I was just thinking about putting in some code to
recognize duplicate aggregates (eg, "sum(foo)" appearing twice in the
same query). nodeAgg.c could do this relatively cheaply, since it has
to make a list of the aggregate expressions to be computed, anyway.
I'm not sure about recognizing duplicated sub-SELECT expressions; it
could possibly be done but some thought would have to be given to
regards, tom lane
In response to
pgsql-performance by date
|Next:||From: Tom Lane||Date: 2002-12-26 23:43:39|
|Subject: Re: View performance |
|Previous:||From: Bruno Wolff III||Date: 2002-12-26 20:36:56|
|Subject: Re: View performance|