From: Dan Ports <drkp@csail.mit.edu>
To: pgsql-hackers@postgresql.org, Kevin Grittner <Kevin.Grittner@wicourts.gov>
Subject: Repeated PredicateLockRelation calls during seqscan
Date: Wed, 22 Jun 2011 00:58:50 -0400
Message-ID: <20110622045850.GN83336@csail.mit.edu> (raw)
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.
Dan
--
Dan R. K. Ports MIT CSAIL http://drkp.net/Attachments:predlock-seqscan.patch (text/x-diff, 823B) downloaddiff --git a/src/backend/executor/nodeSeqscan.c b/src/backend/executor/nodeSeqscan.cindex f356874..32a8f56 100644--- a/src/backend/executor/nodeSeqscan.c+++ b/src/backend/executor/nodeSeqscan.c@@ -113,9 +113,13 @@ SeqRecheck(SeqScanState *node, TupleTableSlot *slot)
TupleTableSlot *
ExecSeqScan(SeqScanState *node)
{
- PredicateLockRelation(node->ss_currentRelation,- node->ss_currentScanDesc->rs_snapshot);- node->ss_currentScanDesc->rs_relpredicatelocked = true;+ if (!node->ss_currentScanDesc->rs_relpredicatelocked)+ {+ PredicateLockRelation(node->ss_currentRelation,+ node->ss_currentScanDesc->rs_snapshot);+ node->ss_currentScanDesc->rs_relpredicatelocked = true; + }+
return ExecScan((ScanState *) node,
(ExecScanAccessMtd) SeqNext,
(ExecScanRecheckMtd) SeqRecheck);
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: drkp@csail.mit.edu, Kevin.Grittner@wicourts.gov
Subject: Re: Repeated PredicateLockRelation calls during seqscan
In-Reply-To: <20110622045850.GN83336@csail.mit.edu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox