Re: Behavior of GENERATED columns per SQL2003

From: "Simon Riggs" <simon(at)2ndquadrant(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Zoltan Boszormenyi" <zb(at)cybertec(dot)at>, <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: Behavior of GENERATED columns per SQL2003
Date: 2007-05-10 20:51:19
Message-ID: 1178830280.10861.236.camel@silverbirch.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 2007-05-10 at 10:11 -0400, Tom Lane wrote:

> As for GENERATED ALWAYS AS (expr), now that we understand that it's not
> supposed to define a virtual column, what's the point? You can get the
> same behavior with a trivial BEFORE INSERT/UPDATE trigger that
> recomputes the derived value, and you don't have to buy into the rather
> ill-defined spec behavior (in particular the point that the generated
> column is effectively undefined during trigger firing seems really
> poorly done). In fact, given that the only plausible use-cases involve
> expressions that are expensive to compute, a trigger can probably do
> *better* than the built-in feature, since it can make use of application
> knowledge about when a recomputation is really necessary. The current
> patch recomputes the expression on every UPDATE, and would have a hard
> time being any brighter than that, given that we don't know what BEFORE
> triggers might do to the row.

We do need virtual columns, whether the spec requires them or not. They
would allow us to completely remove the column value when using
value-list based partitioning, giving considerable space savings for
VLDBs.

ISTM that we should interpret this as a requirement for a virtual
column. We can always move from that to a stored column if the spec
becomes more specific, though it would be harder to move the other way.
And as you point out, storing the value would make no sense.

--
Simon Riggs
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2007-05-10 21:14:24 Re: Feature lists for 8.3 and 8.4
Previous Message Andrew Hammond 2007-05-10 20:23:47 Re: Feature lists for 8.3 and 8.4