Limits

v3.0.0

Every numeric limit and cap in KDBS, with its default, its config key, and what happens when it is reached.

In this article

KDBS has two kinds of limits: fixed limits built into the engine, and caps you set in the server config. A cap never silently truncates a result. Depending on the cap, the statement fails, the work falls back to a slower path that gives the same answer, or a value is not cached.

Identifiers and keys

LimitValueConfig keyWhen exceeded
Primary-key id space, per table[1, 2^48 - 1] = 1 to 281474976710655noneA supplied key outside the range is refused OutOfRange with its byte position. When a table’s id space is used up, inserts are refused OutOfRange; ids never wrap. SHOW BUDGET warns at 90% used.
Issued-key redraws8noneAn issued key that meets a concurrently supplied key 8 times in a row is refused AlreadyExists.
Primary-key column typean integer typenoneAny other type is refused at CREATE TABLE. The id is stored in 48 bits whatever the declared width.
Cores1 to 64, and not more than the machine reportscoresThe server refuses to start.
User columns, whole instanceabout 7,800noneCREATE TABLE is refused once the catalog’s reserved page range is full. DROP TABLE frees its column rows.

Rows per statement

LimitDefaultConfig keyWhen exceeded
Rows in one INSERT ... VALUES1024max_insert_rows (at least 1)The whole statement is refused and nothing is inserted: ERR INSERT of <n> rows exceeds max_insert_rows (<cap>).
Rows one statement may read100,000,000max_rows_touched (0 = unlimited)The statement is refused ResourceExhausted, not retryable. Also bounds SHOW RELAYOUT <table>’s page census.
Rows one ORDER BY may hold1,048,576sort_max_rowsThe statement fails, naming the key. There is no spill to disk and no partial result. A LIMIT caps what is held at offset + limit. ORDER BY <primary key> ascending needs no sort and is never limited.
Groups in one aggregated statement65,536aggregate_max_groupsThe statement fails, naming the key. Nothing is returned.
DISTINCT entries in one statement, summed over its sets1,048,576aggregate_max_distinctThe statement fails, naming the key.
Rows in a join’s in-memory build65,536join_build_max_rows (0 = no build)No error. The join falls back to per-row walks for the rest of the statement, with the same answer.
Lock-table entries per transaction65,536max_locks_per_txnThe statement is refused ResourceExhausted, not retryable. Use shorter transactions, or write by primary-key range, which takes one entry for the range.

Query shape

LimitValueWhen exceeded
ORDER BY keys8NOT_IMPLEMENTED with the byte position.
Subquery nesting below the outer query4 levelsThe fifth level is refused with its byte position.
Scalar subquery result1 rowCardinalityViolation at run time, not retryable.
GROUP BY columns in an assertionno cap

Values and columns

LimitValueWhen exceeded
Largest single value8144 bytes (one var-heap page)NotImplemented.
varchar cell widthinline_cell_width, default 64, range 16 to 4096A value longer than width − 3 bytes is stored out of line; it is not refused below 8144 bytes.
varchar(N)16 ≤ N ≤ 4096N is a cell width, not a maximum length.
char(N)N bytesA longer value is refused. A value containing a NUL byte is refused.
decimal(p, s)p ≤ 38; up to 18 is stored in 8 bytes, 19 to 38 in 16 bytesPrecision and scale are both required.
SUMchecked int64Overflow fails the statement; it never wraps.
UPDATE arithmeticchecked in the result typeA result out of range is OutOfRange at that row; division by zero is InvalidArgument.

Indexes, Cabins and assertions

LimitDefaultConfig keyWhen exceeded
Index key columns4noneNOT_IMPLEMENTED with the byte of the extra column.
Index covered columns8noneRefused with the byte of the extra column.
Cabin columns1 per CabinnoneA second column is refused.
Distinct values one Cabin observes4096cabin_max_values (0 = observe nothing)The value is not observed and is served by a scan. Results are unchanged.
Entries per value in one Cabin4096cabin_max_entries_per_valueSame as above.
Pages for optimizer-managed Cabins1024cabin_optimizer_page_budgetThe optimizer keeps the Cabins it manages within this budget.
Assertion bounda non-negative integer literalnoneA negative or non-literal bound is refused. COUNT(*) <= 0 and < 1 are refused.

Time limits

LimitDefaultConfig keyWhen exceeded
Explicit transaction lifetime60,000 mstxn_lifetime_ceiling_ms (0 refused)The server rolls the transaction back. The next statement, COMMIT included, is refused RESOURCE_EXHAUSTED until the client sends ROLLBACK. Checked every quarter of the ceiling, so the rollback comes between 1× and 1.25× of it. Autocommit statements and bulk-load sessions are exempt. A running statement is never interrupted.
Wait before a lock wait is a fault1000 mslock_wait_fault_net_ms (0 = refuse at once)The waiting statement is aborted, never the holder, and the fault is logged. A normal wait ends earlier, when the holder commits or rolls back.
PURGE waiting for older readers1 snoneRefused TXN_CONFLICT retryable=1; nothing is purged.
relaxed commit loss window10,000 µsrelaxed_flush_interval_usNot an error; the commit is synced.
WAL drain cadence1000 µswal_drain_interval_usNot an error.
Checkpoint cadence5000 mscheckpoint_interval_msNot an error.
TCP keepalive idle60 s, at most 32767tcp_keepalive_sA vanished client, or one that leaves a reply unread, is closed after about twice this.
Idle open backup1 hournoneThe backup is aborted.

Memory and storage

LimitDefaultConfig keyWhen exceeded
Buffer poolrequired, no defaultbuffer_pool_frames (8 KiB frames)A statement that needs more frames than the pool can free is refused ResourceExhausted. Below the floor (resident system and Bound Cabin pages plus 256 frames), the server refuses to mount.
WAL segment size64 MiBnone (fixed per volume)
WAL archive fail-closed threshold4 segments (256 MiB) free on the WAL filesystemnoneWhile archiving is failing, every statement that writes the log is refused. Reads continue.
Backup copy rateup to 256 MiB/snone

Protocol (KWP/1)

LimitValueWhen exceeded
Named statements per session64RESOURCE_EXHAUSTED, not retryable.
Portals per session64RESOURCE_EXHAUSTED, not retryable.
Frame length a client should accept4 bytes to 16 MiBClients should refuse a frame length outside this range.