Neil Conway <neilc@samurai.com> writes:
> ... replaces two ReleaseBuffer() + ReadBuffer() pairs with
> ReleaseAndReadBuffer(). (Is this still worth doing? It seems it no
> longer saves a lock acquire/release, but perhaps it will again be a win
> in some future version of the bufmgr...)
I think there is no longer any noticeable win except in the case where
the old and new pages are actually the same. Which is probably unlikely
to be true inside an index AM (it is a useful win for random access into
a heap for instance). But as you say it might someday again be useful.
My advice is to combine if and only if you're not contorting the code
to do so.
> BTW, this idiom occurs a few times:
> if (BufferIsValid(buf))
> {
> ReleaseBuffer(buf);
> buf = InvalidBuffer;
> }
I'd leave it as-is; ISTM to be more easily understandable than the
alternatives you suggest.
regards, tom lane