mirror of
https://github.com/postgres/postgres.git
synced 2025-11-13 16:22:44 +03:00
Measure the number of all-visible pages for use in index-only scan costing.
Add a column pg_class.relallvisible to remember the number of pages that were all-visible according to the visibility map as of the last VACUUM (or ANALYZE, or some other operations that update pg_class.relpages). Use relallvisible/relpages, instead of an arbitrary constant, to estimate how many heap page fetches can be avoided during an index-only scan. This is pretty primitive and will no doubt see refinements once we've acquired more field experience with the index-only scan mechanism, but it's way better than using a constant. Note: I had to adjust an underspecified query in the window.sql regression test, because it was changing answers when the plan changed to use an index-only scan. Some of the adjacent tests perhaps should be adjusted as well, but I didn't do that here.
This commit is contained in:
@@ -55,6 +55,7 @@ hashbuild(PG_FUNCTION_ARGS)
|
||||
IndexBuildResult *result;
|
||||
BlockNumber relpages;
|
||||
double reltuples;
|
||||
double allvisfrac;
|
||||
uint32 num_buckets;
|
||||
HashBuildState buildstate;
|
||||
|
||||
@@ -67,7 +68,7 @@ hashbuild(PG_FUNCTION_ARGS)
|
||||
RelationGetRelationName(index));
|
||||
|
||||
/* Estimate the number of rows currently present in the table */
|
||||
estimate_rel_size(heap, NULL, &relpages, &reltuples);
|
||||
estimate_rel_size(heap, NULL, &relpages, &reltuples, &allvisfrac);
|
||||
|
||||
/* Initialize the hash index metadata page and initial buckets */
|
||||
num_buckets = _hash_metapinit(index, reltuples, MAIN_FORKNUM);
|
||||
|
||||
Reference in New Issue
Block a user