Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VOu3t-0000w6-Vo for pgsql-performance@arkaria.postgresql.org; Wed, 25 Sep 2013 18:43:46 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VOu3t-0007K5-1Y for pgsql-performance@arkaria.postgresql.org; Wed, 25 Sep 2013 18:43:45 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VOu3r-0007Jy-R8 for pgsql-performance@postgresql.org; Wed, 25 Sep 2013 18:43:43 +0000 Received: from moutng.kundenserver.de ([212.227.17.9]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VOu3m-0004dQ-MD for pgsql-performance@postgresql.org; Wed, 25 Sep 2013 18:43:43 +0000 Received: from anarazel.de (p54AF4270.dip0.t-ipconnect.de [84.175.66.112]) by mrelayeu.kundenserver.de (node=mrbap3) with ESMTP (Nemesis) id 0MIw6j-1VQow61yTR-002XVp; Wed, 25 Sep 2013 20:43:31 +0200 Received: by anarazel.de (Postfix, from userid 1000) id 8EEA2101FD6; Wed, 25 Sep 2013 20:43:30 +0200 (CEST) Date: Wed, 25 Sep 2013 20:43:30 +0200 From: Andres Freund To: Jeff Janes Cc: Josh Berkus , "pgsql-performance@postgresql.org" Subject: Re: Planner performance extremely affected by an hanging transaction (20-30 times)? Message-ID: <20130925184330.GC5578@awork2.anarazel.de> References: <1379944816.30390.YahooMailNeo@web162903.mail.bf1.yahoo.com> <5815.1380018947@sss.pgh.pa.us> <5241CF2A.2070309@agliodbs.com> <20130925175312.GB5578@awork2.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Provags-ID: V02:K0:kFa9HyeEh3yHRScx/egpqKoeA5tr3wrvY55SyXcXXgo XEjxET3w3Q9cfeaNCOag8OMZnSJ6i3NBuYrnJpOmFnGKxTEMtU Q2W6kEwp2AynOXOjR+BF2Np2EBE6vqRJh7V0uUlwK+3R7KVjpt doWvnKY78B+NwBtXuJHGDuL+i/z0VdmNWkGv/Vn0I83eFQDZ3p ckXDIMt9Eiw+wiNtcZOCyRazgR7ztB/btqWc1XnTDio9kjaNv+ /EduKRd4S0gkepY9XiDP9/GYfjow5hPaNXxUpiqitwZzUBBNV2 +2VTx0Ht8i77iCO3NN4IxyNnVlc4e2KCKL3lGlvFTxc7LrbJ8J 8erlPBP4bDge4kIoLGkDfAIaUz45qU+xFwQRxw6/U X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 2013-09-25 11:17:51 -0700, Jeff Janes wrote: > On Wed, Sep 25, 2013 at 10:53 AM, Andres Freund wrote: > > > On 2013-09-25 00:06:06 -0700, Jeff Janes wrote: > > > > On 09/20/2013 03:01 PM, Jeff Janes wrote:> 3) Even worse, asking if a > > > > given transaction has finished yet can be a > > > > > serious point of system-wide contention, because it takes the > > > > > ProcArrayLock, once per row which needs to be checked. So you have > > 20 > > > > > processes all fighting over the ProcArrayLock, each doing so 1000 > > > > times per > > > > > query. > > > > That should be gone in master, we don't use SnapshotNow anymore which > > had those TransactionIdIsInProgress() calls you're probably referring > > to. The lookups discussed in this thread now use the statement's > > snapshot. And all those have their own copy of the currently running > > transactions. > See HeapTupleSatisfiesMVCC, near line 943 of tqual.c: > > else if (TransactionIdIsInProgress(HeapTupleHeaderGetXmin(tuple))) > return false; > else if (TransactionIdDidCommit(HeapTupleHeaderGetXmin(tuple))) > SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED, > HeapTupleHeaderGetXmin(tuple)); > Hm, sorry, misrembered things a bit there. > If we guarded that check by moving up line 961 to before 943: > > if (XidInMVCCSnapshot(HeapTupleHeaderGetXmin(tuple), snapshot)) > return false; /* treat as still in progress */ > > Then we could avoid the contention, as that check only refers to local > memory. That wouldn't be correct afaics - the current TransactionIdIsInProgress callsite is only called when no HEAP_XMIN_COMMITTED was set. So you would have to duplicate it. > As far as I can tell, the only downside of doing that is that, since hint > bits might be set later, it is possible some dirty pages will get written > unhinted and then re-dirtied by the hint bit setting, when more aggressive > setting would have only one combined dirty write instead. But that seems > rather hypothetical, and if it really is a problem we should probably > tackle it directly rather than by barring other optimizations. I am - as evidenced - too tired to think about this properly, but I think you might be right here. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance