From 146c83c045625d6f0072dd96045ebbc54582be05 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 6 Apr 2007 19:22:38 +0000 Subject: [PATCH] Fix some now-obsolete comments about the space used by various data types. --- doc/src/sgml/array.sgml | 6 +++--- doc/src/sgml/datatype.sgml | 41 +++++++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/doc/src/sgml/array.sgml b/doc/src/sgml/array.sgml index 74e9e083f70..ec59d8e6a88 100644 --- a/doc/src/sgml/array.sgml +++ b/doc/src/sgml/array.sgml @@ -1,4 +1,4 @@ - + Arrays @@ -10,8 +10,8 @@ PostgreSQL allows columns of a table to be defined as variable-length multidimensional arrays. Arrays of any - built-in or user-defined base type can be created. (Arrays of - composite types or domains are not yet supported, however.) + built-in or user-defined base type or enum type can be created. + (Arrays of composite types or domains are not yet supported, however.) diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index fc5be3a1061..8bcaf717607 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -1,4 +1,4 @@ - + Data Types @@ -516,7 +516,7 @@ NUMERIC type is more akin to varchar(n) than to char(n).) The actual storage requirement is two bytes for each group of four decimal digits, - plus eight bytes overhead. + plus five to eight bytes overhead. @@ -842,9 +842,9 @@ ALTER SEQUENCE tablename_ money - 4 bytes + 8 bytes currency amount - -21474836.48 to +21474836.47 + -92233720368547758.08 to +92233720368547758.07 @@ -975,12 +975,13 @@ ALTER SEQUENCE tablename_ - The storage requirement for data of these types is 4 bytes plus the - actual string, and in case of character plus the - padding. Long strings are compressed by the system automatically, so - the physical requirement on disk might be less. Long values are also - stored in background tables so they do not interfere with rapid - access to the shorter column values. In any case, the longest + The storage requirement for a short string (up to 126 bytes) is 1 byte + plus the actual string, which includes the space padding in the case of + character. Longer strings have 4 bytes overhead instead + of 1. Long strings are compressed by the system automatically, so + the physical requirement on disk might be less. Very long values are also + stored in background tables so that they do not interfere with rapid + access to shorter column values. In any case, the longest possible character string that can be stored is about 1 GB. (The maximum value that will be allowed for n in the data type declaration is less than that. It wouldn't be very useful to @@ -994,8 +995,10 @@ ALTER SEQUENCE tablename_ There are no performance differences between these three types, - apart from the increased storage size when using the blank-padded - type. While character(n) has performance + apart from increased storage size when using the blank-padded + type, and a few extra cycles to check the length when storing into + a length-constrained column. While + character(n) has performance advantages in some other database systems, it has no such advantages in PostgreSQL. In most situations text or character varying should be used @@ -1080,7 +1083,7 @@ SELECT b, char_length(b) FROM test2; "char" 1 byte - single-character internal type + single-byte internal type name @@ -1122,7 +1125,7 @@ SELECT b, char_length(b) FROM test2; bytea - 4 bytes plus the actual binary string + 1 or 4 bytes plus the actual binary string variable-length binary string @@ -2879,13 +2882,13 @@ SELECT person.name, holidays.num_weeks FROM person, holidays cidr - 12 or 24 bytes + 7 or 19 bytes IPv4 and IPv6 networks inet - 12 or 24 bytes + 7 or 19 bytes IPv4 and IPv6 hosts and networks @@ -3188,6 +3191,12 @@ SELECT * FROM test; + + A bit string value requires 1 byte for each group of 8 bits, plus + 5 or 8 bytes overhead depending on the length of the string + (but long values may be compressed or moved out-of-line, as explained + in for character strings). +