mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
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.
This commit is contained in:
14
src/backend/utils/cache/lsyscache.c
vendored
14
src/backend/utils/cache/lsyscache.c
vendored
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.163 2009/08/10 05:46:50 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.164 2009/12/29 20:11:45 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Eventually, the index information should go through here, too.
|
||||
@ -2524,6 +2524,9 @@ get_typmodout(Oid typid)
|
||||
* Given the table and attribute number of a column, get the average
|
||||
* width of entries in the column. Return zero if no data available.
|
||||
*
|
||||
* Currently this is only consulted for individual tables, not for inheritance
|
||||
* trees, so we don't need an "inh" parameter.
|
||||
*
|
||||
* Calling a hook at this point looks somewhat strange, but is required
|
||||
* because the optimizer calls this function without any other way for
|
||||
* plug-ins to control the result.
|
||||
@ -2540,10 +2543,11 @@ get_attavgwidth(Oid relid, AttrNumber attnum)
|
||||
if (stawidth > 0)
|
||||
return stawidth;
|
||||
}
|
||||
tp = SearchSysCache(STATRELATT,
|
||||
tp = SearchSysCache(STATRELATTINH,
|
||||
ObjectIdGetDatum(relid),
|
||||
Int16GetDatum(attnum),
|
||||
0, 0);
|
||||
BoolGetDatum(false),
|
||||
0);
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
|
||||
@ -2609,7 +2613,7 @@ get_attstatsslot(HeapTuple statstuple,
|
||||
|
||||
if (values)
|
||||
{
|
||||
val = SysCacheGetAttr(STATRELATT, statstuple,
|
||||
val = SysCacheGetAttr(STATRELATTINH, statstuple,
|
||||
Anum_pg_statistic_stavalues1 + i,
|
||||
&isnull);
|
||||
if (isnull)
|
||||
@ -2658,7 +2662,7 @@ get_attstatsslot(HeapTuple statstuple,
|
||||
|
||||
if (numbers)
|
||||
{
|
||||
val = SysCacheGetAttr(STATRELATT, statstuple,
|
||||
val = SysCacheGetAttr(STATRELATTINH, statstuple,
|
||||
Anum_pg_statistic_stanumbers1 + i,
|
||||
&isnull);
|
||||
if (isnull)
|
||||
|
Reference in New Issue
Block a user