Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 7FD74633B34 for ; Thu, 2 Apr 2009 14:40:58 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 59697-04 for ; Thu, 2 Apr 2009 14:40:56 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp.andrew.cmu.edu (SMTP.ANDREW.CMU.EDU [128.2.11.61]) by mail.postgresql.org (Postfix) with ESMTP id 2D228635D59 for ; Thu, 2 Apr 2009 14:40:56 -0300 (ADT) Received: from LISA.WV.CC.CMU.EDU (LISA.WV.CC.CMU.EDU [128.237.228.159]) (user=tonyceb mech=PLAIN (0 bits)) by smtp.andrew.cmu.edu (8.14.3/8.13.8) with ESMTP id n32HerLL008323 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 2 Apr 2009 13:40:54 -0400 Message-ID: <49D4F8A5.7090009@andrew.cmu.edu> Date: Thu, 02 Apr 2009 13:40:53 -0400 From: Tony Cebzanov User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.6.0 MIME-Version: 1.0 To: Craig Ringer CC: pgsql-sql@postgresql.org Subject: Re: Performance problem with row count trigger References: <49D4CA3A.3050005@andrew.cmu.edu> <49D4EB7A.1070002@postnewspapers.com.au> In-Reply-To: <49D4EB7A.1070002@postnewspapers.com.au> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-PMX-Version: 5.5.3.366731, Antispam-Engine: 2.7.0.366912, Antispam-Data: 2009.3.26.141625 X-SMTP-Spam-Clean: 8% (BODY_SIZE_1800_1899 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, __BOUNCE_CHALLENGE_SUBJ 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0, __USER_AGENT 0) X-SMTP-Spam-Score: 8% X-Scanned-By: MIMEDefang 2.60 on 128.2.11.61 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/17 X-Sequence-Number: 32363 Hi Craig, thanks for your help. Craig Ringer wrote: > MVCC bloat from the constant updates to the assoc_count table, maybe? That's what a coworker suggested might be happening. The fact that a no-op trigger performs fine but the UPDATE trigger doesn't would seem to confirm that it's something in the trigger SQL and not in the trigger mechanism itself. > If you're using 8.3, I'd expect HOT to save you here. Are you using an > older version of PostgreSQL? If not, have you by any chance defined an > index on assoc_count ? I'm running 8.3.7, which is the most recent version from Macports. There's no index of any kind on dataset.assoc_count. Having read up on HOT, it sounds like it would be helpful. Is there anything I need to do to enable HOT in 8.3.7, or is it always used? > Also, try to keep records in your `dataset' table as narrow as possible. > If the catalog_id, t_begin, t_end, ctime and mtime fields do not change > almost as often as the assoc_count field, split them into a separate > table with a foreign key referencing dataset_id, rather than storing > them directly in the dataset table. ctime is the creation time of the dataset, so it's never supposed to be updated. mtime is the last time the dataset was changed, and there's another trigger to update that timestamp whenever the dataset table changes. So, at best, I'd be able to remove the ctime column from the dataset table, but I'd have to add the foreign key, so I don't think that would be helpful. Your mention of the ctime and mtime columns made me think the update timestamp trigger may be contributing to the problem as well (since the assoc INSERT trigger would presumably cause the dataset UPDATE trigger to fire), but dropping that trigger yielded no improvement, so I think it's something else.