aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorPeter Geoghegan <pg@bowt.ie>2025-04-04 13:58:05 -0400
committerPeter Geoghegan <pg@bowt.ie>2025-04-04 13:58:05 -0400
commit21a152b37f36c9563d1b0b058fe1436baf578b4c (patch)
tree667c7fb8614d019fbbf53b9e39f7d03990e9d0f2 /src/include
parentcf2655a9029aff63dd567dbbdcdee15ec969905d (diff)
downloadpostgresql-21a152b37f36c9563d1b0b058fe1436baf578b4c.tar.gz
postgresql-21a152b37f36c9563d1b0b058fe1436baf578b4c.zip
Improve nbtree skip scan primitive scan scheduling.
Don't allow nbtree scans with skip arrays to end any primitive scan on its first leaf page without giving some consideration to how many times the scan's arrays advanced while changing at least one skip array (though continue not caring about the number of array advancements that only affected SAOP arrays, even during skip scans with SAOP arrays). Now when a scan performs more than 3 such array advancements in the course of reading a single leaf page, it is taken as a signal that the next page is unlikely to be skippable. We'll therefore continue the ongoing primitive index scan, at least until we can perform a recheck against the next page's finaltup. Testing has shown that this new heuristic occasionally makes all the difference with skip scans that were expected to rely on the "passed first page" heuristic added by commit 9a2e2a28. Without it, there is a remaining risk that certain kinds of skip scans will never quite manage to clear the initial hurdle of performing a primitive scan that lasts beyond its first leaf page (or that such a skip scan will only clear that initial hurdle when it has already wasted noticeably-many cycles due to inefficient primitive scan scheduling). Follow-up to commits 92fe23d9 and 9a2e2a28. Author: Peter Geoghegan <pg@bowt.ie> Reviewed-By: Matthias van de Meent <boekewurm+postgres@gmail.com> Discussion: https://postgr.es/m/CAH2-Wz=RVdG3zWytFWBsyW7fWH7zveFvTHed5JKEsuTT0RCO_A@mail.gmail.com
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/nbtree.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h
index ebbdd83a8c1..ebca02588d3 100644
--- a/src/include/access/nbtree.h
+++ b/src/include/access/nbtree.h
@@ -1118,10 +1118,11 @@ typedef struct BTReadPageState
/*
* Private _bt_checkkeys state used to manage "look ahead" optimization
- * (only used during scans with array keys)
+ * and primscan scheduling (only used during scans with array keys)
*/
int16 rechecks;
int16 targetdistance;
+ int16 nskipadvances;
} BTReadPageState;