diff options
| author | Tom Lane | 2011-10-08 00:13:02 +0000 |
|---|---|---|
| committer | Tom Lane | 2011-10-08 00:14:13 +0000 |
| commit | a2822fb9337a21f98ac4ce850bb4145acf47ca27 (patch) | |
| tree | c239fe9a32ff0225e906711a76348cee1567f0d8 /src/include/optimizer | |
| parent | caa1054df8408b165e5f66ff25c87b6dd0a0a1e7 (diff) | |
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.
Diffstat (limited to 'src/include/optimizer')
| -rw-r--r-- | src/include/optimizer/cost.h | 4 | ||||
| -rw-r--r-- | src/include/optimizer/pathnode.h | 1 | ||||
| -rw-r--r-- | src/include/optimizer/var.h | 2 |
3 files changed, 5 insertions, 2 deletions
diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h index 604df335d2d..125808ae980 100644 --- a/src/include/optimizer/cost.h +++ b/src/include/optimizer/cost.h @@ -52,6 +52,7 @@ extern PGDLLIMPORT int effective_cache_size; extern Cost disable_cost; extern bool enable_seqscan; extern bool enable_indexscan; +extern bool enable_indexonlyscan; extern bool enable_bitmapscan; extern bool enable_tidscan; extern bool enable_sort; @@ -67,7 +68,8 @@ extern double index_pages_fetched(double tuples_fetched, BlockNumber pages, double index_pages, PlannerInfo *root); extern void cost_seqscan(Path *path, PlannerInfo *root, RelOptInfo *baserel); extern void cost_index(IndexPath *path, PlannerInfo *root, IndexOptInfo *index, - List *indexQuals, List *indexOrderBys, RelOptInfo *outer_rel); + List *indexQuals, List *indexOrderBys, + bool indexonly, RelOptInfo *outer_rel); extern void cost_bitmap_heap_scan(Path *path, PlannerInfo *root, RelOptInfo *baserel, Path *bitmapqual, RelOptInfo *outer_rel); extern void cost_bitmap_and_node(BitmapAndPath *path, PlannerInfo *root); diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h index ee02732fe1c..38c8c1c9a35 100644 --- a/src/include/optimizer/pathnode.h +++ b/src/include/optimizer/pathnode.h @@ -34,6 +34,7 @@ extern IndexPath *create_index_path(PlannerInfo *root, List *indexorderbys, List *pathkeys, ScanDirection indexscandir, + bool indexonly, RelOptInfo *outer_rel); extern BitmapHeapPath *create_bitmap_heap_path(PlannerInfo *root, RelOptInfo *rel, diff --git a/src/include/optimizer/var.h b/src/include/optimizer/var.h index 5d7e2d93e91..4fd0052f2df 100644 --- a/src/include/optimizer/var.h +++ b/src/include/optimizer/var.h @@ -31,7 +31,7 @@ typedef enum } PVCPlaceHolderBehavior; extern Relids pull_varnos(Node *node); -extern void pull_varattnos(Node *node, Bitmapset **varattnos); +extern void pull_varattnos(Node *node, Index varno, Bitmapset **varattnos); extern bool contain_var_clause(Node *node); extern bool contain_vars_of_level(Node *node, int levelsup); extern int locate_var_of_level(Node *node, int levelsup); |
