Re: statement-level trigger sample out there?

Поиск
Список
Период
Сортировка
От Gerardo Herzig
Тема Re: statement-level trigger sample out there?
Дата
Msg-id 474F106A.5080107@fmed.uba.ar
обсуждение исходный текст
Ответ на Re: statement-level trigger sample out there?  (Stephen Cook <sclists@gmail.com>)
Ответы Re: statement-level trigger sample out there?
Список pgsql-sql
Stephen Cook wrote:

> I am curious (coming from a MS SQL Server background, I just started 
> playing with PostgreSQL recently).
>
> What type of situation would warrant a statement-level trigger that 
> can't access the old and new values?  Without that access, isn't the 
> only information you get is the fact that an operation occurred on the 
> table?  Or am I missing something?
>
> -- Stephen

What about this. Suppose you have this table "planets":
planet_name | star_id|....

There is a lot of stars, right? And if a very common query involves a 
"select planet_name, count(*) from planets group by star_id"....Well, if 
there is 1.000.000.000 of galaxies, and 1.000.000.000.000 of stars per 
galaxy...Thats a lot of planets to count!!! So maybe you want a helper 
table who maintains such of subtotals.

Well, each time you discover a new galaxy, insert every planet in the 
monster table, and *after* all the inserts, run a trigger for updating 
the helper table.

Cheers.
Gerardo


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

Предыдущее
От: "Christian Kindler"
Дата:
Сообщение: Re: statement-level trigger sample out there?
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: statement-level trigger sample out there?