X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BC8CE52803 for ; Tue, 17 May 2005 14:47:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50561-10 for ; Tue, 17 May 2005 17:47:24 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9041152813 for ; Tue, 17 May 2005 14:47:23 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4HHlOd7000707; Tue, 17 May 2005 13:47:24 -0400 (EDT) To: "Manuel Wenger" Cc: pgsql-performance@postgresql.org Subject: Re: Trigger performance problem In-reply-to: <5A838EC3CE99804991EF9D37875C5A6F3343@exchange.ticinocom.com> References: <5A838EC3CE99804991EF9D37875C5A6F3343@exchange.ticinocom.com> Comments: In-reply-to "Manuel Wenger" message dated "Mon, 16 May 2005 15:06:49 +0200" Date: Tue, 17 May 2005 13:47:23 -0400 Message-ID: <705.1116352043@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/306 X-Sequence-Number: 12470 "Manuel Wenger" 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