Re: Seq scans status update - Mailing list pgsql-patches

From Tom Lane
Subject Re: Seq scans status update
Date
Msg-id 10742.1180388199@sss.pgh.pa.us
Whole thread Raw
In response to Re: Seq scans status update  (Heikki Linnakangas <heikki@enterprisedb.com>)
Responses Re: Seq scans status update
Re: Seq scans status update
List pgsql-patches
Heikki Linnakangas <heikki@enterprisedb.com> writes:
> One idea is to keep track which pins are taken using the bulk strategy.
> It's a bit tricky when a buffer is pinned multiple times since we don't
> know which ReleaseBuffer corresponds which ReadBuffer, but perhaps we
> could get away with just a flag per pinned buffer. Set the flag when a
> buffer is pinned with bulk strategy and it wasn't pinned by us before,
> and clear it when it's pinned with another strategy. I'm thinking we
> steal one bit from PrivateRefCount for this.

Seems like a mess.  Why don't we just fix it so there's no need for
different behavior at Unpin time?  The facts on the ground are that
the current patch's change in UnpinBuffer is a no-op anyway, because
of the tupletableslot interference.

The behavior I'm imagining is just that when we try to take a buffer
from the ring, if its usage count exceeds 1 then drop it from the ring
and get another buffer.  1 would be the expected case if no one had
touched it since we last used it.

>> A heapscan would pin the buffer only once and hence bump its count at
>> most once, so I don't see a big problem here.  Also, I'd argue that
>> buffers that had a positive usage_count shouldn't get sucked into the
>> ring to begin with.

> True, except that with the synchronized scans patch two synchronized
> scans will pin the buffer twice.

Hmm.  But we probably don't want the same buffer in two different
backends' rings, either.  You *sure* the sync-scan patch has no
interaction with this one?

One other question: I see the patch sets the threshold for switching
from normal to ring-buffer heapscans at table size = NBuffers.  Why
so high?  I'd have expected maybe at most NBuffers/4 or NBuffers/10.
If you don't want a seqscan blowing out your buffer cache, you surely
don't want it blowing out 90% of the cache either.

            regards, tom lane

pgsql-patches by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Seq scans status update
Next
From: Gregory Stark
Date:
Subject: Re: Seq scans status update