首页 > 解决方案 > 每个数据库限制的 Postgresql 关系

问题描述

在 Postgresql 文档附录 K ( https://www.postgresql.org/docs/12/limits.html ) 中有一个限制列表:

+------------------------+-----------------------------------------------------------------------+------------------------------------------------------------------------+
| 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 default BLCKSZ of 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                                                                  |                                                                        |
+------------------------+-----------------------------------------------------------------------+------------------------------------------------------------------------+
| identifier length      | 63 bytes                                                              | can be increased by recompiling PostgreSQL                             |
+------------------------+-----------------------------------------------------------------------+------------------------------------------------------------------------+
| indexes per table      | unlimited                                                             | constrained by maximum relations per database                          |
+------------------------+-----------------------------------------------------------------------+------------------------------------------------------------------------+
| columns per index      | 32                                                                    | can be increased by recompiling PostgreSQL                             |
+------------------------+-----------------------------------------------------------------------+------------------------------------------------------------------------+
| partition keys         | 32                                                                    | can be increased by recompiling PostgreSQL                             |
+------------------------+-----------------------------------------------------------------------+------------------------------------------------------------------------+

“每个数据库的关系”行是指数据库中每一行的关系总数,或声明的外键数?

例如,两个带有外键的表加入都算作数据库中的 1 个关系?还是 1 * 行数(1.000 行等于 1.000 个关系)?

非常感谢你的帮助 :)

标签: postgresql

解决方案


“关系”是存储在目录表中的任何内容pg_class:表、视图、序列、索引、物化视图、分区表和分区索引。

该限制主要是理论上的,实际上,如果您有 100000 个左右的关系,您将遇到麻烦。


推荐阅读