Re: Derived columns / denormalization

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Jamie Tufnell" <diesql(at)googlemail(dot)com>
Cc: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Derived columns / denormalization
Date: 2009-01-16 04:06:35
Message-ID: 27584.1232078795@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Jamie Tufnell" <diesql(at)googlemail(dot)com> writes:
> item_count int -- this is derived from (select count(*) from items
> where group_id = id)
> ...

> item_count would be updated by insert/update/delete triggers on the
> items table, hopefully that would ensure it is always correct?

> I'm wondering is what I'm trying to do here pretty standard and are
> there any gotchas I should be aware of?

Concurrent updates to the items table make this much harder than
it might first appear. If you're willing to serialize all your updating
transactions then you can make it work, but ...

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Erik Jones 2009-01-16 16:42:11 Re: Derived columns / denormalization
Previous Message Jamie Tufnell 2009-01-16 03:52:25 Derived columns / denormalization