Database Capacity Constraints and Configuration Boundaries
These entries outline the technical boundaries for PostgreSQL and SQLite. They detail specific maximums for data sizes, object counts, column numbers, and statement lengths. While PostgreSQL maintains several hard-coded limits that may require recompilation to change, SQLite offers greater flexibility, allowing most constraints to be adjusted at run-time through specific configuration parameters and functions.
PostgreSQL Hard Limits and Constraints
PostgreSQL imposes several hard limits. The database size is unlimited, but the number of databases is capped at 4,294,950,911 and relations per database at 1,431,650,303. A relation's size is limited to 32 TB with a default BLCKSZ of 8192 bytes. Rows per table are limited by the number of tuples that can fit on 4,294,967,295 pages. Tables can have up to 1,600 columns, though this is further constrained by the requirement that a tuple must fit on a single page; for instance, 1,600 bigint columns would exceed a heap page. CHECK constraints per table are limited to 32,767. Result sets are limited to 1,664 columns, and field size is 1 GB. Indexes per table are unlimited, subject to the relations per database limit, but can have at most 32 columns. Partition keys are limited to 32. Identifier length is 63 bytes, function arguments are limited to 100, and query parameters are capped at 65,535. Additionally, tables can store a theoretical maximum of 2^32 out-of-line values, though performance may degrade as the 32-bit OID space fills up. Several limits, such as columns per index, partition keys, identifier length, and function arguments, can be increased by recompiling PostgreSQL.
Source: https://www.postgresql.org/docs/current/limits.html
SQLite Constraints and Configuration Parameters
SQLite enforces several limits. The maximum length for strings or BLOBs (and consequently rows) is defined by SQLITE_MAX_LENGTH, defaulting to 1 billion bytes. SQLITE_MAX_COLUMN limits columns in tables, indices, views, and various SQL clauses, defaulting to 2000. The maximum SQL statement length is 1,000,000,000 bytes via SQLITE_MAX_SQL_LENGTH. Joins are limited to 64 tables. Expression tree depth defaults to 1000 via SQLITE_MAX_EXPR_DEPTH. Function arguments are limited by SQLITE_MAX_FUNCTION_ARG, defaulting to 1000 since version 3.48.0. Compound SELECT terms are limited to 500 via SQLITE_MAX_COMPOUND_SELECT. LIKE or GLOB patterns are capped at 50,000 bytes. Host parameter numbers are limited by SQLITE_MAX_VARIABLE_NUMBER, defaulting to 32766 in newer versions. Trigger recursion depth defaults to 1000. The number of attached databases defaults to 10, with a maximum of 125. Database file size is constrained by SQLITE_MAX_PAGE_COUNT, defaulting to 4294967294 pages; at a 65536-byte page size, this reaches approximately 281 terabytes. The theoretical maximum number of rows is 2^64, though disk limits make this unreachable. The maximum number of objects in a schema is 10 million via SQLITE_LIMIT_SCHEMA. Most limits can be adjusted at run-time using sqlite3_limit().