diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2024-01-13 18:14:53 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2024-01-13 18:14:53 +0100 |
commit | 4f622503d6de975ac87448aea5cea7de4bc140d5 (patch) | |
tree | c09756e667e5150678e8ebf9aee6c1cd5e376a96 /src/backend/utils/cache/lsyscache.c | |
parent | 45da69371ebfc4d6982695e58791989660c1cc33 (diff) | |
download | postgresql-4f622503d6de975ac87448aea5cea7de4bc140d5.tar.gz postgresql-4f622503d6de975ac87448aea5cea7de4bc140d5.zip |
Make attstattarget nullable
This changes the pg_attribute field attstattarget into a nullable
field in the variable-length part of the row. If no value is set by
the user for attstattarget, it is now null instead of previously -1.
This saves space in pg_attribute and tuple descriptors for most
practical scenarios. (ATTRIBUTE_FIXED_PART_SIZE is reduced from 108
to 104.) Also, null is the semantically more correct value.
The ANALYZE code internally continues to represent the default
statistics target by -1, so that that code can avoid having to deal
with null values. But that is now contained to the ANALYZE code.
Only the DDL code deals with attstattarget possibly null.
For system columns, the field is now always null. The ANALYZE code
skips system columns anyway.
To set a column's statistics target to the default value, the new
command form ALTER TABLE ... SET STATISTICS DEFAULT can be used. (SET
STATISTICS -1 still works.)
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://www.postgresql.org/message-id/flat/4da8d211-d54d-44b9-9847-f2a9f1184c76@eisentraut.org
Diffstat (limited to 'src/backend/utils/cache/lsyscache.c')
-rw-r--r-- | src/backend/utils/cache/lsyscache.c | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index 8ec83561bfa..f730aa26c47 100644 --- a/src/backend/utils/cache/lsyscache.c +++ b/src/backend/utils/cache/lsyscache.c @@ -873,33 +873,6 @@ get_attnum(Oid relid, const char *attname) } /* - * get_attstattarget - * - * Given the relation id and the attribute number, - * return the "attstattarget" field from the attribute relation. - * - * Errors if not found. - */ -int -get_attstattarget(Oid relid, AttrNumber attnum) -{ - HeapTuple tp; - Form_pg_attribute att_tup; - int result; - - tp = SearchSysCache2(ATTNUM, - ObjectIdGetDatum(relid), - Int16GetDatum(attnum)); - if (!HeapTupleIsValid(tp)) - elog(ERROR, "cache lookup failed for attribute %d of relation %u", - attnum, relid); - att_tup = (Form_pg_attribute) GETSTRUCT(tp); - result = att_tup->attstattarget; - ReleaseSysCache(tp); - return result; -} - -/* * get_attgenerated * * Given the relation id and the attribute number, |