Hard Limits and Quotas for PostgreSQL and SQLite
These entries detail the maximum sizes and counts enforced by PostgreSQL and SQLite. They cover constraints on database and table sizes, column and row counts, and limits on identifiers and parameters. The reports describe the consequences of exceeding these boundaries, such as the SQLITE_FULL error, and note which limits are fixed or configurable via compilation and run-time interfaces.
PostgreSQL Hard Limits
PostgreSQL enforces several hard limits, though practical constraints like disk space or performance may apply sooner. Database size is unlimited, and there is a limit of 4,294,950,911 databases and 1,431,650,303 relations per database. Relations are limited to 32 TB with the default BLCKSZ of 8192 bytes. Rows per table are limited by the number of tuples fitting onto 4,294,967,295 pages. Tables can have up to 1,600 columns, further restricted by the requirement that the tuple fits on a single 8192-byte heap page; dropped columns also count toward this limit. Other limits include 32,767 CHECK constraints per table, 1,664 columns in a result set, and a 1 GB field size. Indexes per table are unlimited, though constrained by maximum relations per database. Indices and partition keys are limited to 32, while function arguments are limited to 100, though these can be increased by recompiling. Identifier length is 63 bytes, and query parameters are limited to 65,535. Additionally, there is a theoretical maximum of 2^32 out-of-line values per table, though filling this OID space can slow INSERT/UPDATE statements.
Source: https://www.postgresql.org/docs/current/limits.html
SQLite Database Limits and Customization
SQLite enforces various size and count limits, many of which are configurable at compile-time via macros or at run-time using the sqlite3_limit() interface. Default limits include 1 billion bytes for strings, BLOBs, and SQL statements (SQLITE_MAX_LENGTH and SQLITE_MAX_SQL_LENGTH), and 2,000 columns (SQLITE_MAX_COLUMN). Other defaults are 1,000 for expression tree depth (SQLITE_MAX_EXPR_DEPTH), function arguments (SQLITE_MAX_FUNCTION_ARG), and trigger recursion depth (SQLITE_MAX_TRIGGER_DEPTH). Compound SELECT terms are limited to 500, and LIKE/GLOB patterns to 50,000 bytes. Host parameter numbers are capped at 32,766 (since version 3.32.0), and attached databases to 10. The maximum database size is 4,294,967,294 pages, which can reach approximately 281 terabytes depending on page size; exceeding this via data insertion returns SQLITE_FULL. Joins are strictly limited to 64 tables. Schema objects can be capped at 10 million starting with version 3.54.0. While some limits can be raised, others, like join counts, cannot. Run-time limits are specifically useful for restricting untrusted external code to prevent denial-of-service attacks.