X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 164DD53DA3 for ; Tue, 3 May 2005 09:33:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 20521-06 for ; Tue, 3 May 2005 12:33:04 +0000 (GMT) Received: from ns.aprote.ee (ns.aprote.ee [80.235.78.106]) by svr1.postgresql.org (Postfix) with ESMTP id BDF8F5349B for ; Tue, 3 May 2005 09:32:42 -0300 (ADT) Received: Message by Barricade ns.aprote.ee with ESMTP id j43CZEaf020565 for ; Tue, 3 May 2005 15:35:16 +0300 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.0.6556.0 Subject: Re: Function or Field? Date: Tue, 3 May 2005 15:32:42 +0300 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Function or Field? Thread-Index: AcVP3DOGlGK2/T0dSq2tzanfkHcKsA== From: "Tambet Matiisen" To: , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/33 X-Sequence-Number: 21346 >=20 > 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=20 > (before insert or update into vendding table) to alter this field. > b) Create a view or function that check the all venddings=20 > (in vendding table) for the specified product and return the=20 > last vendding information? >=20 You could also use "computed field" approach described here (see Tip):=20 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=20 both in products table and in all indexes. You need to VACUUM and REINDEX regularly. Been there, done that. Tambet