Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 606041337B4F for ; Tue, 9 Nov 2010 19:17:50 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 08830-03 for ; Tue, 9 Nov 2010 23:17:43 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 167AD1336B42 for ; Tue, 9 Nov 2010 19:17:42 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id oA9NHgwH020216; Tue, 9 Nov 2010 18:17:42 -0500 (EST) To: "Kevin Grittner" cc: pgsql-performance@postgresql.org Subject: Re: anti-join chosen even when slower than old plan In-reply-to: <4CD97FDE02000025000374D1@gw.wicourts.gov> References: <4CD9663502000025000374B1@gw.wicourts.gov> <4CD97FDE02000025000374D1@gw.wicourts.gov> Comments: In-reply-to "Kevin Grittner" message dated "Tue, 09 Nov 2010 17:07:42 -0600" Date: Tue, 09 Nov 2010 18:17:42 -0500 Message-ID: <20215.1289344662@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201011/123 X-Sequence-Number: 41147 "Kevin Grittner" writes: > "Kevin Grittner" wrote: >> samples % symbol name >> 2320174 33.7617 index_getnext > I couldn't resist seeing where the time went within this function. > Over 13.7% of the opannotate run time was on this bit of code: > /* > * The xmin should match the previous xmax value, else chain is > * broken. (Note: this test is not optional because it protects > * us against the case where the prior chain member's xmax aborted > * since we looked at it.) > */ > if (TransactionIdIsValid(scan->xs_prev_xmax) && > !TransactionIdEquals(scan->xs_prev_xmax, > HeapTupleHeaderGetXmin(heapTuple->t_data))) > break; > I can't see why it would be such a hotspot, but it is. Main-memory access waits, maybe? If at_chain_start is false, that xmin fetch would be the first actual touch of a given heap tuple, and could be expected to have to wait for a cache line to be pulled in from RAM. However, you'd have to be spending a lot of time chasing through long HOT chains before that would happen enough to make this a hotspot... regards, tom lane