Re: trigger speed

From: Sim Zacks <sim(at)compulab(dot)co(dot)il>
To: Joseph Shraibman <jks(at)selectacast(dot)net>
Subject: Re: trigger speed
Date: 2006-09-10 08:48:26
Message-ID: 4503D15A.1070505@compulab.co.il
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

A statement level trigger is basically a notification that the table has
been touched. You do not have access to the new or old tables.
You can also write a DO ALSO rule on the table, which will accomplish
what you want.

Joseph Shraibman wrote:
> I have a trigger that updates a count table, based on status. The count
> table looks like this:
>
> key status count
> a 1 300
> a 2 400
> b 1 100
> b 2 200
>
> The problem is that for large updates when I do "UPDATE table SET status
> = 1 WHERE status = 2 and key = 'a';" the row level trigger fires for
> each row updated, decrementing the a 2 row and incrmenting the a 1 row.
> For large updates this really slows things down.
>
> Question #1: how do I speed this up? I need a way to run a trigger on
> all rows at once.
>
> Q #2: how do satement level triggers work? The examples in the pg docs
> only show row level triggers.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message maarten 2006-09-10 11:33:28 Re: Reinstall problem of PostgreSQL in Windows XP
Previous Message Sim Zacks 2006-09-10 07:57:58 Re: Is this logical?