Обсуждение: Triggers or code?

Поиск
Список
Период
Сортировка

Triggers or code?

От
DM
Дата:
Hello There,

I have a table x and a history table x_hist, whats the best way to update the history table.

should i need to use triggers or embed a code in my script to update the history table?

what is the performance impact of a trigger versus embedding the code in the script?

thanks for your time.

- Deepak

Re: Triggers or code?

От
André Fernandes
Дата:
Trigger is the way to go.

André.


Date: Mon, 23 Aug 2010 11:42:21 -0700
Subject: [PERFORM] Triggers or code?
From: dm.aeqa@gmail.com
To: pgsql-performance@postgresql.org

Hello There,

I have a table x and a history table x_hist, whats the best way to update the history table.

should i need to use triggers or embed a code in my script to update the history table?

what is the performance impact of a trigger versus embedding the code in the script?

thanks for your time.

- Deepak

Re: Triggers or code?

От
Bob Lunney
Дата:
That depends on your application's requirements.  If a transaction on table X fails, do you still want the history (noting the failure)?  If so, go with embedding the code in your script.  If you only want history for successful transactions, a trigger will take care of that for you automatically.

Bob Lunney 

--- On Mon, 8/23/10, DM <dm.aeqa@gmail.com> wrote:

From: DM <dm.aeqa@gmail.com>
Subject: [PERFORM] Triggers or code?
To: pgsql-performance@postgresql.org
Date: Monday, August 23, 2010, 2:42 PM

Hello There,

I have a table x and a history table x_hist, whats the best way to update the history table.

should i need to use triggers or embed a code in my script to update the history table?

what is the performance impact of a trigger versus embedding the code in the script?

thanks for your time.

- Deepak