2 Appendix K. PostgreSQL Limits
4 Table K.1 describes various hard limits of PostgreSQL. However,
5 practical limits, such as performance limitations or available disk
6 space may apply before absolute hard limits are reached.
8 Table K.1. PostgreSQL Limitations
9 Item Upper Limit Comment
10 database size unlimited
11 number of databases 4,294,950,911
12 relations per database 1,431,650,303
13 relation size 32 TB with the default BLCKSZ of 8192 bytes
14 rows per table limited by the number of tuples that can fit onto
16 columns per table 1,600 further limited by tuple size fitting on a
17 single page; see note below
18 columns in a result set 1,664
20 indexes per table unlimited constrained by maximum relations per
22 columns per index 32 can be increased by recompiling PostgreSQL
23 partition keys 32 can be increased by recompiling PostgreSQL
24 identifier length 63 bytes can be increased by recompiling PostgreSQL
25 function arguments 100 can be increased by recompiling PostgreSQL
26 query parameters 65,535
28 The maximum number of columns for a table is further reduced as the
29 tuple being stored must fit in a single 8192-byte heap page. For
30 example, excluding the tuple header, a tuple made up of 1,600 int
31 columns would consume 6400 bytes and could be stored in a heap page,
32 but a tuple of 1,600 bigint columns would consume 12800 bytes and would
33 therefore not fit inside a heap page. Variable-length fields of types
34 such as text, varchar, and char can have their values stored out of
35 line in the table's TOAST table when the values are large enough to
36 require it. Only an 18-byte pointer must remain inside the tuple in the
37 table's heap. For shorter length variable-length fields, either a
38 4-byte or 1-byte field header is used and the value is stored inside
41 Columns that have been dropped from the table also contribute to the
42 maximum column limit. Moreover, although the dropped column values for
43 newly created tuples are internally marked as null in the tuple's null
44 bitmap, the null bitmap also occupies space.
46 Each table can store a theoretical maximum of 2^32 out-of-line values;
47 see Section 66.2 for a detailed discussion of out-of-line storage. This
48 limit arises from the use of a 32-bit OID to identify each such value.
49 The practical limit is significantly less than the theoretical limit,
50 because as the OID space fills up, finding an OID that is still free
51 can become expensive, in turn slowing down INSERT/UPDATE statements.
52 Typically, this is only an issue for tables containing many terabytes
53 of data; partitioning is a possible workaround.