Re: Repeated PredicateLockRelation calls during seqscan

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Dan Ports <drkp(at)csail(dot)mit(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Subject: Re: Repeated PredicateLockRelation calls during seqscan
Date: 2011-06-22 09:07:04
Message-ID: 4E01B0B8.2020205@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2011-06-22 09:25:53 Re: Coding style point: "const" in function parameter declarations
Previous Message Heikki Linnakangas 2011-06-22 06:58:02 Re: Coding style point: "const" in function parameter declarations