summaryrefslogtreecommitdiff
path: root/src/include/optimizer
diff options
context:
space:
mode:
authorTom Lane2010-11-19 22:31:50 +0000
committerTom Lane2010-11-19 22:31:50 +0000
commit0f61d4dd1b4f95832dcd81c9688dac56fd6b5687 (patch)
tree9bb1e825dc323f19cc1969b1bcbdfd13b80fce98 /src/include/optimizer
parentfe24d781612700646bfb3e08925e34c43926f9df (diff)
Improve relation width estimation for subqueries.
As per the ancient comment for set_rel_width, it really wasn't much good for relations that aren't plain tables: it would never find any stats and would always fall back on datatype-based estimates, which are often pretty silly. Fix that by copying up width estimates from the subquery planning process. At some point we might want to do this for CTEs too, but that would be a significantly more invasive patch because the sub-PlannerInfo is no longer accessible by the time it's needed. I refrained from doing anything about that, partly for fear of breaking the unmerged CTE-related patches. In passing, also generate less bogus width estimates for whole-row Vars. Per a gripe from Jon Nelson.
Diffstat (limited to 'src/include/optimizer')
-rw-r--r--src/include/optimizer/cost.h2
-rw-r--r--src/include/optimizer/plancat.h2
2 files changed, 3 insertions, 1 deletions
diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h
index e1dcd6df14..8df1b95abe 100644
--- a/src/include/optimizer/cost.h
+++ b/src/include/optimizer/cost.h
@@ -121,6 +121,8 @@ extern void set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
RelOptInfo *inner_rel,
SpecialJoinInfo *sjinfo,
List *restrictlist);
+extern void set_subquery_size_estimates(PlannerInfo *root, RelOptInfo *rel,
+ PlannerInfo *subroot);
extern void set_function_size_estimates(PlannerInfo *root, RelOptInfo *rel);
extern void set_values_size_estimates(PlannerInfo *root, RelOptInfo *rel);
extern void set_cte_size_estimates(PlannerInfo *root, RelOptInfo *rel,
diff --git a/src/include/optimizer/plancat.h b/src/include/optimizer/plancat.h
index de7de84cb3..ca7b2c6469 100644
--- a/src/include/optimizer/plancat.h
+++ b/src/include/optimizer/plancat.h
@@ -31,7 +31,7 @@ extern void get_relation_info(PlannerInfo *root, Oid relationObjectId,
extern void estimate_rel_size(Relation rel, int32 *attr_widths,
BlockNumber *pages, double *tuples);
-extern int32 get_relation_data_width(Oid relid);
+extern int32 get_relation_data_width(Oid relid, int32 *attr_widths);
extern bool relation_excluded_by_constraints(PlannerInfo *root,
RelOptInfo *rel, RangeTblEntry *rte);