Re: Trigger performance problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Manuel Wenger" <manuel(dot)wenger(at)ticinocom(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Trigger performance problem
Date: 2005-05-17 17:47:23
Message-ID: 705.1116352043@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

"Manuel Wenger" <manuel(dot)wenger(at)ticinocom(dot)com> writes:
> We're having a performance problem with PostgresQL 8.0.2 running on
> RHEL3 Update 4. There is a frequently updated table logging all our ADSL
> customer logins which has 2 related triggers. An INSERT on that table,
> "calls", takes about 300ms to execute according to the logs, and the
> process takes up to 30% of the server CPU. When removing the triggers it
> drops to 10-20ms.

You need to figure out exactly which operation(s) inside the triggers
is so expensive. You could try removing commands one at a time and
timing the modified triggers.

Just on general principles, I'd guess that this might be the problem:

> delete from currentip where ip is null;

Since an IS NULL test isn't indexable by a normal index, this is going
to cause a full scan of the currentip table every time. I don't really
understand why you need that executed every time anyway ... why is it
this trigger's responsibility to clean out null IPs? But if you really
do need to make that run quickly, you could create a partial index with
a WHERE clause of "ip is null".

regards, tom lane

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message lists 2005-05-17 17:53:39 Re: Trigger performance problem
Previous Message Josh Berkus 2005-05-16 16:17:20 Re: checkpoint segments