From 649b5ec7c8a3050a30bd6d36003ba3a681c9a198 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 29 Dec 2009 20:11:45 +0000 Subject: Add the ability to store inheritance-tree statistics in pg_statistic, and teach ANALYZE to compute such stats for tables that have subclasses. Per my proposal of yesterday. autovacuum still needs to be taught about running ANALYZE on parent tables when their subclasses change, but the feature is useful even without that. --- src/backend/utils/adt/selfuncs.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'src/backend/utils/adt/selfuncs.c') diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 20d4180e9b..8bc26cb6e9 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.263 2009/10/21 20:38:58 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.264 2009/12/29 20:11:45 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -4046,20 +4046,13 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, !vardata->freefunc) elog(ERROR, "no function provided to release variable stats with"); } - else if (rte->inh) - { - /* - * XXX This means the Var represents a column of an append - * relation. Later add code to look at the member relations and - * try to derive some kind of combined statistics? - */ - } else if (rte->rtekind == RTE_RELATION) { - vardata->statsTuple = SearchSysCache(STATRELATT, + vardata->statsTuple = SearchSysCache(STATRELATTINH, ObjectIdGetDatum(rte->relid), Int16GetDatum(var->varattno), - 0, 0); + BoolGetDatum(rte->inh), + 0); vardata->freefunc = ReleaseSysCache; } else @@ -4196,10 +4189,11 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, else if (index->indpred == NIL) { vardata->statsTuple = - SearchSysCache(STATRELATT, + SearchSysCache(STATRELATTINH, ObjectIdGetDatum(index->indexoid), Int16GetDatum(pos + 1), - 0, 0); + BoolGetDatum(false), + 0); vardata->freefunc = ReleaseSysCache; } if (vardata->statsTuple) @@ -5830,10 +5824,11 @@ btcostestimate(PG_FUNCTION_ARGS) } else { - vardata.statsTuple = SearchSysCache(STATRELATT, + vardata.statsTuple = SearchSysCache(STATRELATTINH, ObjectIdGetDatum(relid), Int16GetDatum(colnum), - 0, 0); + BoolGetDatum(rte->inh), + 0); vardata.freefunc = ReleaseSysCache; } } @@ -5856,10 +5851,11 @@ btcostestimate(PG_FUNCTION_ARGS) } else { - vardata.statsTuple = SearchSysCache(STATRELATT, + vardata.statsTuple = SearchSysCache(STATRELATTINH, ObjectIdGetDatum(relid), Int16GetDatum(colnum), - 0, 0); + BoolGetDatum(false), + 0); vardata.freefunc = ReleaseSysCache; } } -- cgit v1.2.1