# Appendix K. PostgreSQL Limits

Table K.1describes various hard limits of PostgreSQL. However, practical limits, such as performance limitations or available disk space may apply before absolute hard limits are reached.

Table K.1. PostgreSQL Limitations

Item Upper Limit Comment
database size unlimited
number of databases 4,294,950,911
relations per database 1,431,650,303
relation size 32 TB with the defaultBLCKSZof 8192 bytes
rows per table limited by the number of tuples that can fit onto 4,294,967,295 pages
columns per table 1600 further limited by tuple size fitting on a single page; see note below
field size 1 GB
标识符长度 63 字节 可以通过重新编译PostgreSQL来增加
每个表的索引 无限 受每个数据库的最大关系限制
每个索引的列 32 可以通过重新编译PostgreSQL来增加
分区键 32 可以通过重新编译PostgreSQL来增加

由于存储的元组必须适合单个 8192 字节的堆页,因此表的最大列数会进一步减少。例如,排除元组头,一个由 1600 组成的元组整数列将消耗 6400 字节并且可以存储在堆页中,但是 1600 的元组大整数列将消耗 12800 字节,因此不适合堆页。类型的可变长度字段,例如文本,varchar, 和字符当值大到足以需要它时,可以将它们的值存储在表的 TOAST 表中。只有一个 18 字节的指针必须保留在表堆中的元组内。对于较短长度的可变长度字段,使用 4 字节或 1 字节的字段标头,并将值存储在堆元组内。

已从表中删除的列也会影响最大列限制。此外,虽然新创建的元组的删除列值在元组的空位图中内部标记为空,但空位图也占用空间。