-
+
Data Types
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.
|
money
- 4 bytes
+ 8 bytes
currency amount
- -21474836.48 to +21474836.47
+ -92233720368547758.08 to +92233720368547758.07
- 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
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
|
"char"
1 byte
- single-character internal type
+ single-byte internal type
|
name
|
bytea
- 4 bytes plus the actual binary string
+ 1 or 4 bytes plus the actual binary string
variable-length binary string
|
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
+ 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).
+