KDBS
KDBS is a user-space database engine written in C++20. It targets short transactions that read and write by key, joins that follow keys, and durability chosen by the caller. It keeps the feature surface narrow and concentrates on two things. One is that the rules the data must obey are declared in the schema and the engine enforces them on every write. The other is acceleration structures that cannot change results: for every structure the engine consults for speed, deleting it never makes a query return different rows. The sandbox on this site uses KDBS v3.4.17.
KDBS states that it is neither a general-purpose SQL DBMS nor a dialect-compatibility layer for another DBMS. It therefore rejects, with a position (byte offset) and a reason, many syntaxes that are familiar from other DBMSs. The tables in this document collect those differences.
Key Specifications
| Item | Value |
|---|---|
| Implementation | C++20, Linux. One cooperative reactor per core (thread-per-core); the buffer pool and WAL are shared |
| Storage unit | 8KB page |
| Table storage | Default BTREE: a B+ tree clustered by tuple key. HEAP is also available (tuple key) |
| Row format | Fixed-length tuples. UPDATE overwrites in place, and long values go to an immutable side store (var-heap) |
| Row identifier | 48-bit tuple key. A key, once written, is not handed to another row until PURGE |
| Strings | The N in varchar(N) is the cell width (in bytes), not a maximum length. A single value is at most 8,144 bytes |
| Numbers | Integers, decimal(p,s) (p ≤ 38). float is rejected |
| NULL | Columns are NOT NULL by default. You must write NULL to allow it |
| Isolation levels | Two: READ COMMITTED (default) and REPEATABLE READ. SERIALIZABLE is rejected (transactions) |
| Durability | Three levels: strict, group (default), relaxed (durability levels) |
| Protocol | Its own binary protocol KWP/1 (port 15432, loopback by default). Not PostgreSQL wire compatible |
| Authentication | Off (default) or SCRAM-SHA-256. Roles readonly, readwrite, admin |
| Reserved words | Only 11 (JOIN, ON, AS, IN, EXISTS, NOT, BETWEEN, LEFT, RIGHT, FULL, OUTER) |
Execution Structure
The structure of the reactor threads and the buffer pool is in Memory and Thread Structure, and the protocol and portals are in Connections, Portals, and the Statement Cache.
Statements run by two paths (step chain and query layer).
- Step chain: A statement that reads as the basic grammar is compiled at parse time into a chain of steps (key lookup, probe, range, scan, sub-chain). There is no general plan search, and the one thing the engine chooses is the join order of the inner join block (join order and plans).
- Query layer: The rest of SQL, such as outer joins, set operations, derived tables, expressions in the select list, and
HAVING, takes rows from the engine's single-table lookup for each table and computes on top of them.ANALYZEdoes not explain this path.
Everything the engine learns (Waystone traces, Cabin entries, plan statistics) can be erased, and every query returns the same rows after erasing it. Traces only decide where to look first, and statistics only decide the join order.
SQL That Differs from Other DBMSs
| Item | Other DBMSs | KDBS |
|---|---|---|
| Table alias | FROM orders o | FROM orders AS o only. A bare alias is rejected so that a misspelled keyword is not read as an alias |
| Type conversion | Implicit conversion | None. '20' against an int column, or 5 against a varchar column, is rejected at compile time |
| Date and time literals | DATE '2025-01-01' | '2025-01-01' (date), '2025-01-01 00:00:00' (timestamp). No type prefix |
' inside a string | 'it''s' | No escape. A value that contains a single quote cannot be written as a literal |
| Comments | --, /* */ | -- only |
| CTE, window functions | Supported | WITH and OVER return NOT_IMPLEMENTED |
Outer joins, UNION, HAVING, derived tables, scalar subqueries | Supported | The query layer answers them. ANALYZE does not explain them |
| Sorting | Spills to disk | No spill. The statement fails if it exceeds sort_max_rows (default 1,048,576) |
NULLS FIRST/LAST | Supported | None. NULL is the largest value (fixed to the PostgreSQL rule) |
| Hints | /*+ … */, OPTION (…) | None. An administrator pins the join order and access method with CREATE PLAN |
| Auto increment | SERIAL, IDENTITY | None. If INSERT omits the tuple key, the engine issues one |
IF NOT EXISTS, SAVEPOINT | Supported | None |
Rejections fall into three kinds. InvalidArgument means the statement is wrong. NOT_IMPLEMENTED means the design accepts it but it is not built yet (it may work in a later version). UNSUPPORTED means the structure cannot accept it (updating a tuple key, float, and so on).
In the Sandbox
| Item | Value |
|---|---|
| Data | In the tune namespace: 100,000 rows in customers, 2,000,000 rows in orders, 3 rows in grade_cd. Same distribution as the other DBs (common lab environment) |
| Account | sbx_run with the readonly role. Only SELECT, ANALYZE, and BEGIN/ROLLBACK |
| Execution | For each request, BEGIN READ ONLY ISOLATION LEVEL REPEATABLE READ … ROLLBACK. For each statement, it fetches the rows once and the step statistics once through ANALYZE |
| Execution plan table | One step line of ANALYZE is one row. Starts = opens, A-Rows = matched, Buffers = pages |
Configuration and Inspection
-- Tables, indexes, columns (in the admin tool; the sandbox blocks the sys views)
SHOW TABLES;
SHOW INDEXES;
DESCRIBE orders;
-- What one statement actually did
ANALYZE SELECT * FROM orders WHERE ord_id = 42;
-- Cumulative cost per statement shape (calls, time, pages read)
SELECT fetch_id, kind, calls, total_us, rows_examined, pages, shape_text FROM sys.statement_stats;
NOTE KDBS is an engine under development, and its wire protocol and SQL surface have changed over time. This document is based on
v3.4.17-178. Where it differs from the manual (ckdbs/manual/sql/sql.md), it follows the behavior measured in the sandbox (for example, the manual says joins rejectSELECT *, but this version accepts it).
Related pages
- KDBS Memory and Thread Architecture
- KDBS connections, portals, and statement cache
- DBMS Architecture at a Glance
- Tuple Key (Keystone)
- Step Chain and ANALYZE
- Join Order and Plans (CREATE PLAN)
- Cabin and Secondary Indexes
- Waystone
- ASSERTION and TRANSITION
- Durability Levels (strict, group, relaxed)
- Transactions and Isolation Levels
- PostgreSQL
- Oracle Database