Обсуждение: Rules for trigger execution

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

Rules for trigger execution

От
pginfo
Дата:
Hi,

Is it possible in pg to define rules for trigger execution.

I have a table with namy fields and have defined trigger ( in PL/SQL) on
updating.

If I try to update one field from the table and it is not includet in
trigger calculation,
pg takes about 15 min for updating 700K records.

If I do not have trigger installed all is ok as performance.

My Question is how to define that I need trigger execution by changin
only some fields from table?

Will be trigger execution faster if I write it in C ?

regards,
ivan.


Re: Rules for trigger execution

От
Richard Huxton
Дата:
On Wednesday 29 Jan 2003 11:11 am, pginfo wrote:
> Hi,
>
> Is it possible in pg to define rules for trigger execution.
> I have a table with namy fields and have defined trigger ( in PL/SQL) on
> updating.
>
> If I try to update one field from the table and it is not includet in
> trigger calculation, pg takes about 15 min for updating 700K records.
>
> If I do not have trigger installed all is ok as performance.
>
> My Question is how to define that I need trigger execution by changin
> only some fields from table?

Unfortunately, you can't specify firing triggers only on changes to certain
columns (although the docs say this is part of the SQL 99 spec).

> Will be trigger execution faster if I write it in C ?

Almost certainly, although how much faster depends on what the trigger is
doing. The first thing I'd do is test which columns have changed and exit the
trigger function unless it really has to do some work.

--
  Richard Huxton

Re: Rules for trigger execution

От
pginfo
Дата:

Richard Huxton wrote:

> On Wednesday 29 Jan 2003 11:11 am, pginfo wrote:
> > Hi,
> >
> > Is it possible in pg to define rules for trigger execution.
> > I have a table with namy fields and have defined trigger ( in PL/SQL) on
> > updating.
> >
> > If I try to update one field from the table and it is not includet in
> > trigger calculation, pg takes about 15 min for updating 700K records.
> >
> > If I do not have trigger installed all is ok as performance.
> >
> > My Question is how to define that I need trigger execution by changin
> > only some fields from table?
>
> Unfortunately, you can't specify firing triggers only on changes to certain
> columns (although the docs say this is part of the SQL 99 spec).
>
> > Will be trigger execution faster if I write it in C ?
>
> Almost certainly, although how much faster depends on what the trigger is
> doing. The first thing I'd do is test which columns have changed and exit the
> trigger function unless it really has to do some work.
>

I do the same, but it looks that pg calls slow the trigger.No mather if the
trigger do what else.

regards,
ivan.

> --
>   Richard Huxton