From: Tambet Matiisen <t.matiisen@aprote.ee>
To: lucas@presserv.org
To: pgsql-sql@postgresql.org
Subject: Re: Function or Field?
Date: Tue, 3 May 2005 15:32:42 +0300
Message-ID: <A66A11DBF5525341AEF6B8DE39CDE77008807E@black.aprote.com> (raw)
>
> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: t.matiisen@aprote.ee, lucas@presserv.org
Subject: Re: Function or Field?
In-Reply-To: <A66A11DBF5525341AEF6B8DE39CDE77008807E@black.aprote.com>
References: <A66A11DBF5525341AEF6B8DE39CDE77008807E@black.aprote.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox