Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id C2AB2B5DC13 for ; Tue, 27 Sep 2011 21:37:29 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 15711-06 for ; Wed, 28 Sep 2011 00:37:23 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mail-vw0-f46.google.com (mail-vw0-f46.google.com [209.85.212.46]) by mail.postgresql.org (Postfix) with ESMTP id 42366B5DC09 for ; Tue, 27 Sep 2011 21:37:21 -0300 (ADT) Received: by vws1 with SMTP id 1so7098714vws.19 for ; Tue, 27 Sep 2011 17:37:21 -0700 (PDT) Received: by 10.52.72.106 with SMTP id c10mr2475315vdv.356.1317170241117; Tue, 27 Sep 2011 17:37:21 -0700 (PDT) Received: from ayaki.localdomain (58-7-170-220.dyn.iinet.net.au. [58.7.170.220]) by mx.google.com with ESMTPS id cu18sm18116999vdb.12.2011.09.27.17.37.17 (version=SSLv3 cipher=OTHER); Tue, 27 Sep 2011 17:37:19 -0700 (PDT) Message-ID: <4E826C3B.7030504@ringerc.id.au> Date: Wed, 28 Sep 2011 08:37:15 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0.2) Gecko/20110906 Thunderbird/6.0.2 MIME-Version: 1.0 To: Ben Chobot CC: Maria.L.Wilson-1@nasa.gov, "pgsql-performance@postgresql.org" Subject: Re: postgres constraint triggers References: <4E80ADD7.8090008@nasa.gov> <3F7F288F-A4DC-4AFD-B538-FD6C9A943C65@silentmedia.com> In-Reply-To: <3F7F288F-A4DC-4AFD-B538-FD6C9A943C65@silentmedia.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201109/404 X-Sequence-Number: 45180 On 09/27/2011 12:54 PM, Ben Chobot wrote: > On Sep 26, 2011, at 10:52 AM, Maria L. Wilson wrote: > >> Our first try to solve this problem has been to convert these triggers >> into a constraint trigger which allows for DEFERRABLE INITIALLY >> DEFERRED flags. This, we are finding, is forcing the trigger function >> to run after the triggering transaction is completed. We believe this >> will fix our locking problem and hopefully speed up our inserts again. >> >> Any comments or past experiences would certainly be helpful! > > My memory is fuzzy but as I recall, a possible downside to using > deferred constraints was increased memory usage That's right. PostgreSQL doesn't currently support spilling of pending constraint information to disk; it has to keep it in RAM, and with sufficiently huge deferred updates/inserts/deletes it's possible for the backend to run out of RAM to use. > though I cannot see how at the moment. A list of which triggers to run, and on which tuples, must be maintained until those triggers are fired. That list has to be kept somewhere. -- Craig Ringer