Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id DD191B5DBEF for ; Wed, 22 Jun 2011 18:27:21 -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 77458-01 for ; Wed, 22 Jun 2011 21:27:15 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from midnight-anchovy.ambulatoryclam.net (unknown [18.141.0.210]) by mail.postgresql.org (Postfix) with ESMTP id 0EEDEB5DBEA for ; Wed, 22 Jun 2011 18:27:14 -0300 (ADT) Received: by midnight-anchovy.ambulatoryclam.net (Postfix, from userid 1001) id 83E354AC24; Wed, 22 Jun 2011 17:29:50 -0400 (EDT) Date: Wed, 22 Jun 2011 17:29:50 -0400 From: Dan Ports To: Heikki Linnakangas Cc: pgsql-hackers@postgresql.org, Kevin Grittner Subject: Re: Repeated PredicateLockRelation calls during seqscan Message-ID: <20110622212950.GR83336@csail.mit.edu> References: <20110622045850.GN83336@csail.mit.edu> <4E01B0B8.2020205@enterprisedb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4E01B0B8.2020205@enterprisedb.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.107 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RDNS_NONE=0.793 X-Spam-Level: X-Archive-Number: 201106/1914 X-Sequence-Number: 190627 On Wed, Jun 22, 2011 at 12:07:04PM +0300, Heikki Linnakangas wrote: > Hmm, I wonder if we should move this logic to heapam.c. The optimization > to acquire a relation lock straight away should apply to all heap scans, > not only those coming from ExecSeqScan. The distinction is academic at > the moment, because that's the only caller that uses a regular MVCC > snapshot, but it seems like a modularity violation for nodeSeqscan.c to > reach into the HeapScanDesc to set the flag and grab the whole-relation > lock, while heapam.c contains the PredicateLockTuple and > CheckForSerializableConflictOut() calls. On modularity grounds, I think that's a good idea. The other PredicateLock* calls live in the access methods: heapam, nbtree, and indexam for the generic index support. heap_beginscan_internal seems like a reasonable place, as long as we're OK with taking the lock even if the scan is initialized but never called. Note that this hadn't been a reasonable option until last week when we added the check for non-MVCC snapshots, since there are lots of things that use heap scans but SeqScan is the only (currently-existing) one we want to lock. I am rather uneasy about making changes here unless we can be absolutely certain they're right... Dan -- Dan R. K. Ports MIT CSAIL http://drkp.net/