mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Support index-only scans using the visibility map to avoid heap fetches.
When a btree index contains all columns required by the query, and the visibility map shows that all tuples on a target heap page are visible-to-all, we don't need to fetch that heap page. This patch depends on the previous patches that made the visibility map reliable. There's a fair amount left to do here, notably trying to figure out a less chintzy way of estimating the cost of an index-only scan, but the core functionality seems ready to commit. Robert Haas and Ibrar Ahmed, with some previous work by Heikki Linnakangas.
This commit is contained in:
4
src/backend/utils/cache/relcache.c
vendored
4
src/backend/utils/cache/relcache.c
vendored
@@ -3684,10 +3684,10 @@ RelationGetIndexAttrBitmap(Relation relation)
|
||||
}
|
||||
|
||||
/* Collect all attributes used in expressions, too */
|
||||
pull_varattnos((Node *) indexInfo->ii_Expressions, &indexattrs);
|
||||
pull_varattnos((Node *) indexInfo->ii_Expressions, 1, &indexattrs);
|
||||
|
||||
/* Collect all attributes in the index predicate, too */
|
||||
pull_varattnos((Node *) indexInfo->ii_Predicate, &indexattrs);
|
||||
pull_varattnos((Node *) indexInfo->ii_Predicate, 1, &indexattrs);
|
||||
|
||||
index_close(indexDesc, AccessShareLock);
|
||||
}
|
||||
|
@@ -681,6 +681,15 @@ static struct config_bool ConfigureNamesBool[] =
|
||||
true,
|
||||
NULL, NULL, NULL
|
||||
},
|
||||
{
|
||||
{"enable_indexonlyscan", PGC_USERSET, QUERY_TUNING_METHOD,
|
||||
gettext_noop("Enables the planner's use of index-only-scan plans."),
|
||||
NULL
|
||||
},
|
||||
&enable_indexonlyscan,
|
||||
true,
|
||||
NULL, NULL, NULL
|
||||
},
|
||||
{
|
||||
{"enable_bitmapscan", PGC_USERSET, QUERY_TUNING_METHOD,
|
||||
gettext_noop("Enables the planner's use of bitmap-scan plans."),
|
||||
|
@@ -243,6 +243,7 @@
|
||||
#enable_hashagg = on
|
||||
#enable_hashjoin = on
|
||||
#enable_indexscan = on
|
||||
#enable_indexonlyscan = on
|
||||
#enable_material = on
|
||||
#enable_mergejoin = on
|
||||
#enable_nestloop = on
|
||||
|
Reference in New Issue
Block a user