Re: Function or Field?

From: "Tambet Matiisen" <t(dot)matiisen(at)aprote(dot)ee>
To: <lucas(at)presserv(dot)org>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Function or Field?
Date: 2005-05-03 12:32:42
Message-ID: A66A11DBF5525341AEF6B8DE39CDE77008807E@black.aprote.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


>
> Hi.
> What is the better way to store the last record for a translation???
> I.E:
> The data for the last product vendding.
> What is better:
> a) Create a field in "product" table and create a Trigger
> (before insert or update into vendding table) to alter this field.
> b) Create a view or function that check the all venddings
> (in vendding table) for the specified product and return the
> last vendding information?
>

You could also use "computed field" approach described here (see Tip):
http://www.postgresql.org/docs/8.0/interactive/xfunc-sql.html#AEN29483

This allows you to do just what seems simpler and change later on.
No need to touch any other SQL code.

Keep in mind that when using triggers, every update generates a dead
tuple
both in products table and in all indexes. You need to VACUUM and
REINDEX
regularly. Been there, done that.

Tambet

Browse pgsql-sql by date

  From Date Subject
Next Message Frank Bax 2005-05-03 13:41:11 Re: Function or Field?
Previous Message lucas 2005-05-03 12:14:52 Re: Record Log Trigger