mpiot
mpiot

Reputation: 1522

Postgresql relations per database limitations

In the Postgresql docs Appendix K (https://www.postgresql.org/docs/12/limits.html) there is a list of the 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 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                             |
+------------------------+-----------------------------------------------------------------------+------------------------------------------------------------------------+

The line 'relations per database' mean the total number of relations for each row in the database, or the number of declared Foreign Keys ?

For exemple, 2 tables with a Foreign Key to join both count as 1 relation in the database ? Or as 1 * number rows (1.000 rows equals 1.000 relations) ?

Thanks a lot for your help :)

Upvotes: 2

Views: 374

Answers (2)

Laurenz Albe
Laurenz Albe

Reputation: 246268

“Relation” is anything that is stored in the catalog table pg_class: tables, views, sequences, indexes, materialized views, partitioned tables and partitioned indexes.

That limit is mostly theoretical, in practice you will get in trouble if you have 100000 or so relations.

Upvotes: 1

Adrian Klaver
Adrian Klaver

Reputation: 19620

See here:

https://www.postgresql.org/docs/current/tutorial-concepts.html

Relation is essentially a mathematical term for table.

Upvotes: 0

Related Questions