Re: strange perf regression with data checksums
Peter Geoghegan <pg@bowt.ie>
From: Peter Geoghegan <pg@bowt.ie>
To: Tomas Vondra <tomas@vondra.me>
Cc: Aleksander Alekseev <aleksander@timescale.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2025-05-19T16:42:24Z
Lists: pgsql-hackers
On Fri, May 9, 2025 at 9:06 AM Tomas Vondra <tomas@vondra.me> wrote: > Good question. I haven't checked that explicitly, but it's a tiny data > set (15MB) and I observed this even on long benchmarks with tens of > millions of queries. So the hint bits should have been set. > > Also, I should have mentioned the query does an index-only scan, and the > pin/unpin calls are on index pages, not on the heap. We don't actually need to call BufferGetLSNAtomic() from _bt_readpage during index-only scans (nor during bitmap index scans). We can just not call BufferGetLSNAtomic() at all (except during plain index scans), with no possible downside. In general, we call BufferGetLSNAtomic() to stash the page LSN within so->currPos.lsn, for later. so->currPos.lsn provides us with a way to detect whether the page was modified during the period in which we dropped our pin on the leaf page -- plain index scans cannot set LP_DEAD bits on dead index tuples within _bt_killitems() if the page has changed. But, index-only scans never drop the pin on the leaf page to begin with, and so don't even use so->currPos.lsn (bitmap index scans *never* call _bt_killitems(), and so obviously have no possible use for so->currPos.lsn, either). -- Peter Geoghegan
Commits
-
Make _bt_killitems drop pins it acquired itself.
- 7c319f54917f 18.0 landed
- 40aa5ddea1c0 17.6 landed
- c7f25feb3862 16.10 landed
- d2ec671092a1 15.14 landed
- 7c7c0a77dc8a 14.19 landed
- 38c8d298704c 13.22 landed
-
Avoid BufferGetLSNAtomic() calls during nbtree scans.
- e6eed40e4441 18.0 landed
-
Reduce pinning and buffer content locking for btree scans.
- 2ed5b87f96d4 9.5.0 cited