Re: Derived columns / denormalization - Mailing list pgsql-sql

From Tom Lane
Subject Re: Derived columns / denormalization
Date
Msg-id 27584.1232078795@sss.pgh.pa.us
Whole thread Raw
In response to Derived columns / denormalization  ("Jamie Tufnell" <diesql@googlemail.com>)
Responses Re: Derived columns / denormalization  (Erik Jones <ejones@engineyard.com>)
List pgsql-sql
"Jamie Tufnell" <diesql@googlemail.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


pgsql-sql by date:

Previous
From: "Jamie Tufnell"
Date:
Subject: Derived columns / denormalization
Next
From: Erik Jones
Date:
Subject: Re: Derived columns / denormalization