Re: Function or Field?

Поиск
Список
Период
Сортировка
От Tambet Matiisen
Тема Re: Function or Field?
Дата
Msg-id A66A11DBF5525341AEF6B8DE39CDE77008807E@black.aprote.com
обсуждение исходный текст
Ответ на Function or Field?  (lucas@presserv.org)
Список 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


В списке pgsql-sql по дате отправления:

Предыдущее
От: lucas@presserv.org
Дата:
Сообщение: Re: Record Log Trigger
Следующее
От: Frank Bax
Дата:
Сообщение: Re: Function or Field?