Re: Trigger performance problem

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Trigger performance problem
Дата
Msg-id 705.1116352043@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Trigger performance problem  ("Manuel Wenger" <manuel.wenger@ticinocom.com>)
Список pgsql-performance
"Manuel Wenger" <manuel.wenger@ticinocom.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

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

Предыдущее
От: "Manuel Wenger"
Дата:
Сообщение: Trigger performance problem
Следующее
От: lists@boutiquenumerique.com
Дата:
Сообщение: Re: Trigger performance problem