Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 523B6B5DBCB for ; Sun, 26 Jun 2011 10:05:58 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 92470-07 for ; Sun, 26 Jun 2011 13:05:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og124.obsmtp.com (exprod7og124.obsmtp.com [64.18.2.26]) by mail.postgresql.org (Postfix) with ESMTP id 2F430B5D80A for ; Sun, 26 Jun 2011 10:05:50 -0300 (ADT) Received: from mail-ey0-f173.google.com ([209.85.215.173]) (using TLSv1) by exprod7ob124.postini.com ([64.18.6.12]) with SMTP ID DSNKTgcurtr9SVWcCqEaYlgtD3xoGqRwyFQP@postini.com; Sun, 26 Jun 2011 06:05:52 PDT Received: by eyb6 with SMTP id 6so1486676eyb.4 for ; Sun, 26 Jun 2011 06:05:48 -0700 (PDT) Received: by 10.14.53.136 with SMTP id g8mr3569235eec.14.1309093548692; Sun, 26 Jun 2011 06:05:48 -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 j46sm872484eea.6.2011.06.26.06.05.46 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 26 Jun 2011 06:05:47 -0700 (PDT) Message-ID: <4E072EA9.3030200@enterprisedb.com> Date: Sun, 26 Jun 2011 16:05:45 +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: Kevin Grittner CC: drkp@csail.mit.edu, pgsql-hackers@postgresql.org Subject: Re: Repeated PredicateLockRelation calls during seqscan References: <4E05F0D2020000250003EC1D@gw.wicourts.gov> In-Reply-To: <4E05F0D2020000250003EC1D@gw.wicourts.gov> 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/2056 X-Sequence-Number: 190769 On 25.06.2011 22:29, Kevin Grittner wrote: > In looking this over I noticed something else that doesn't seem quite > right. In heapam.c there are two places where the execution of > PredicateLockTuple() is conditioned not just on MVCC visibility, but > also on HeapKeyTest(). I think those calls should be moved to not be > conditioned on that. Otherwise we have a predicate condition being > tested without "locking the gaps", don't we? Locks on heap tuples don't serve the purpose of locking gaps, anyway, because you can't lock anything that doesn't yet exist that way. Locks on index pages and the heap relation serve that purpose. I wonder if we need those PredicateLockTuple() calls in heapam.c at all. You need to take a whole-relation lock on the heap to lock the gaps, to ensure that you conflict newly inserted rows. And if fetch a tuple via an index, you acquire locks on the index pages. What is the point of the PredicateLockTuple() calls? We added the rs_relpredicatelocked mechanism as an optimization, but I'm thinking that it's actually required for correctness to grab a predicate lock on the whole relation when you do a seqscan. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com