Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 4FD29632600 for ; Thu, 2 Apr 2009 13:44:53 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 30753-06 for ; Thu, 2 Apr 2009 13:44:48 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [202.61.230.242]) by mail.postgresql.org (Postfix) with ESMTP id 1BD78632545 for ; Thu, 2 Apr 2009 13:44:50 -0300 (ADT) Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by www.postnewspapers.com.au (Postfix) with ESMTP id 1CA865C148; Fri, 3 Apr 2009 00:44:46 +0800 (WST) Received: from localhost (access [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 101081E0437; Fri, 3 Apr 2009 00:44:46 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (access.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id vp7K+mUa5F2N; Fri, 3 Apr 2009 00:44:42 +0800 (WST) Received: from [192.168.44.68] (203-59-94-220.perm.iinet.net.au [203.59.94.220]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTP id AD01E1E0436; Fri, 3 Apr 2009 00:44:42 +0800 (WST) Message-ID: <49D4EB7A.1070002@postnewspapers.com.au> Date: Fri, 03 Apr 2009 00:44:42 +0800 From: Craig Ringer User-Agent: Thunderbird 2.0.0.21 (X11/20090319) MIME-Version: 1.0 To: Tony Cebzanov Cc: pgsql-sql@postgresql.org Subject: Re: Performance problem with row count trigger References: <49D4CA3A.3050005@andrew.cmu.edu> In-Reply-To: <49D4CA3A.3050005@andrew.cmu.edu> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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/16 X-Sequence-Number: 32362 Tony Cebzanov wrote: > The throughput of the first batch of 1,000 is diminished, but still > tolerable, but after 10,000 inserts, it's gotten much worse. This > pattern continues, to the point where performance is unacceptable after > 20k or 30k inserts. > > To rule out the performance of the trigger mechanism itself, I swapped > the trigger out for one that does nothing. The results were the same as > without the trigger (the first set of numbers), which leads me to > believe there's something about the UPDATE statement in the trigger that > is causing this behavior. MVCC bloat from the constant updates to the assoc_count table, maybe? 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 ? 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. -- Craig Ringer