diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2019-03-30 18:58:55 -0400 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2019-03-30 18:58:55 -0400 |
| commit | 428b260f87e8861ba8e58807b69d433db491c4f4 (patch) | |
| tree | 19291c1fbbbd8cd3186b3789728ed7120a96a624 /src/include/optimizer | |
| parent | ad3107b97324e0c8cf65932294115b6af9db8ded (diff) | |
Speed up planning when partitions can be pruned at plan time.
Previously, the planner created RangeTblEntry and RelOptInfo structs
for every partition of a partitioned table, even though many of them
might later be deemed uninteresting thanks to partition pruning logic.
This incurred significant overhead when there are many partitions.
Arrange to postpone creation of these data structures until after
we've processed the query enough to identify restriction quals for
the partitioned table, and then apply partition pruning before not
after creation of each partition's data structures. In this way
we need not open the partition relations at all for partitions that
the planner has no real interest in.
For queries that can be proven at plan time to access only a small
number of partitions, this patch improves the practical maximum
number of partitions from under 100 to perhaps a few thousand.
Amit Langote, reviewed at various times by Dilip Kumar, Jesper Pedersen,
Yoshikazu Imai, and David Rowley
Discussion: https://postgr.es/m/9d7c5112-cb99-6a47-d3be-cf1ee6862a1d@lab.ntt.co.jp
Diffstat (limited to 'src/include/optimizer')
| -rw-r--r-- | src/include/optimizer/inherit.h | 7 | ||||
| -rw-r--r-- | src/include/optimizer/pathnode.h | 3 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/include/optimizer/inherit.h b/src/include/optimizer/inherit.h index d2418f15cfa..02a23e5b1bf 100644 --- a/src/include/optimizer/inherit.h +++ b/src/include/optimizer/inherit.h @@ -17,6 +17,11 @@ #include "nodes/pathnodes.h" -extern void expand_inherited_tables(PlannerInfo *root); +extern void expand_inherited_rtentry(PlannerInfo *root, RelOptInfo *rel, + RangeTblEntry *rte, Index rti); + +extern bool apply_child_basequals(PlannerInfo *root, RelOptInfo *parentrel, + RelOptInfo *childrel, RangeTblEntry *childRTE, + AppendRelInfo *appinfo); #endif /* INHERIT_H */ diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h index 9e79e1cd63c..3a803b3fd00 100644 --- a/src/include/optimizer/pathnode.h +++ b/src/include/optimizer/pathnode.h @@ -277,10 +277,9 @@ extern Path *reparameterize_path_by_child(PlannerInfo *root, Path *path, */ extern void setup_simple_rel_arrays(PlannerInfo *root); extern void setup_append_rel_array(PlannerInfo *root); +extern void expand_planner_arrays(PlannerInfo *root, int add_size); extern RelOptInfo *build_simple_rel(PlannerInfo *root, int relid, RelOptInfo *parent); -extern void add_appendrel_other_rels(PlannerInfo *root, RelOptInfo *rel, - Index rti); extern RelOptInfo *find_base_rel(PlannerInfo *root, int relid); extern RelOptInfo *find_join_rel(PlannerInfo *root, Relids relids); extern RelOptInfo *build_join_rel(PlannerInfo *root, |
