Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 123C2B5D94C for ; Wed, 22 Jun 2011 06:07:17 -0300 (ADT) 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 26945-05 for ; Wed, 22 Jun 2011 09:07:10 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og115.obsmtp.com (exprod7og115.obsmtp.com [64.18.2.217]) by mail.postgresql.org (Postfix) with ESMTP id 11F7CB5D8BD for ; Wed, 22 Jun 2011 06:07:09 -0300 (ADT) Received: from mail-ey0-f173.google.com ([209.85.215.173]) (using TLSv1) by exprod7ob115.postini.com ([64.18.6.12]) with SMTP ID DSNKTgGwvblQ1r9SGL2SQxbMxLx74nV3kx/Z@postini.com; Wed, 22 Jun 2011 02:07:10 PDT Received: by eyb6 with SMTP id 6so174867eyb.32 for ; Wed, 22 Jun 2011 02:07:07 -0700 (PDT) Received: by 10.14.95.68 with SMTP id o44mr300325eef.208.1308733627619; Wed, 22 Jun 2011 02:07:07 -0700 (PDT) Received: from [90.190.247.247] (247.247.190.90.dyn.estpak.ee [90.190.247.247]) by mx.google.com with ESMTPS id z1sm305824eeb.6.2011.06.22.02.07.05 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 22 Jun 2011 02:07:06 -0700 (PDT) Message-ID: <4E01B0B8.2020205@enterprisedb.com> Date: Wed, 22 Jun 2011 12:07:04 +0300 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.2.17) Gecko/20110606 Icedove/3.1.10 MIME-Version: 1.0 To: Dan Ports CC: pgsql-hackers@postgresql.org, Kevin Grittner Subject: Re: Repeated PredicateLockRelation calls during seqscan References: <20110622045850.GN83336@csail.mit.edu> In-Reply-To: <20110622045850.GN83336@csail.mit.edu> 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=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201106/1867 X-Sequence-Number: 190580 On 22.06.2011 07:58, Dan Ports wrote: > I was looking at ExecSeqScan today and noticed that it invokes > PredicateLockRelation each time it's called, i.e. for each tuple > returned. Any reason we shouldn't skip that call if > rs_relpredicatelocked is already set, as in the attached patch? > > That would save us a bit of overhead, since checking that flag is > cheaper than doing a hash lookup in the local predicate lock table > before bailing out. 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. BTW, isn't bitgetpage() in nodeBitmapHeapscan.c missing PredicateLockTuple() and CheckForSerializableConflictOut() calls in the codepath for a lossy bitmap? In the non-lossy case, heap_hot_search_buffer() takes care of it, but not in the lossy case. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com