Skip site navigation (1) Skip section navigation (2)

Re: View performance

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: View performance
Date: 2002-12-26 20:45:55
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
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
any kind.

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
preserving semantics.

			regards, tom lane

In response to

pgsql-performance by date

Next:From: Tom LaneDate: 2002-12-26 23:43:39
Subject: Re: View performance
Previous:From: Bruno Wolff IIIDate: 2002-12-26 20:36:56
Subject: Re: View performance

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group