Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id E130964FCC3 for ; Tue, 16 Sep 2008 11:01:43 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 45996-04 for ; Tue, 16 Sep 2008 11:01:31 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.25]) by postgresql.org (Postfix) with ESMTP id 1157F64FCF7 for ; Tue, 16 Sep 2008 11:01:30 -0300 (ADT) Received: by ey-out-2122.google.com with SMTP id 6so1133567eyi.61 for ; Tue, 16 Sep 2008 07:01:29 -0700 (PDT) Received: by 10.210.12.18 with SMTP id 18mr1364237ebl.83.1221573689069; Tue, 16 Sep 2008 07:01:29 -0700 (PDT) Received: from ?80.222.33.27? ( [80.222.33.27]) by mx.google.com with ESMTPS id d23sm27412499nfh.11.2008.09.16.07.01.26 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 16 Sep 2008 07:01:28 -0700 (PDT) Message-ID: <48CFBC34.5010802@enterprisedb.com> Date: Tue, 16 Sep 2008 17:01:24 +0300 Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.14 (X11/20080509) MIME-Version: 1.0 To: Simon Riggs CC: pgsql-hackers Subject: Re: Subtransaction commits and Hot Standby References: <1221566023.3913.1823.camel@ebony.2ndQuadrant> In-Reply-To: <1221566023.3913.1823.camel@ebony.2ndQuadrant> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit From: Heikki Linnakangas 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: 200809/1032 X-Sequence-Number: 124161 Simon Riggs wrote: > Subtransactions cause a couple of problems for Hot Standby: Do we need to treat subtransactions any differently from normal transactions? Just treat all subtransactions as top-level transactions until commit, and mark them all as committed when you see the commit record for the top-level transaction. > Right now we lock and unlock the clog for each committed subtransaction > at commit time, which is wasteful. A better scheme: > pre-scan the list of xids to derive list of pages > if we have just a single page to update > { > update all entries on page in one action > } > else > { > loop thru xids marking them all as subcommitted > mark top level transaction committed > loop thus xids again marking them all as committed > } > > All clog updates would be performed page-at-a-time, in ascending xid > order. > > This seems likely to work well since many subtransactions will be on > same clog page as the top-level xid and the locking will often be more > efficient than the current case of repeated single lock acquisitions. It > also means we can skip RecordSubTransactionCommit() entirely, > significantly reducing clog contention. > > Anybody see a problem there? Hmm, I don't see anything immediately wrong with that. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com