Common lab environment
The schema, data distribution, and indexes shared by the KDBS scenarios, and how to measure with ANALYZE
The KDBS scenarios run on the single schema in this document. Tables, columns, row counts, and distributions are the same as in the Oracle environment and the PostgreSQL environment. A scenario with the same number can be run on another DB for comparison. What kind of engine KDBS is is described in the wiki page KDBS.
Tables and data distribution
| Table | Rows | Description |
|---|---|---|
customers | 100,000 | Customers. Grade VIP 1%, GOLD 9%, NORMAL 90%. 5 regions at 20% each |
orders | 2,000,000 | Orders. 2,000 per day from 2023-01-01 to 2025-09-26. ord_id order matches date order |
grade_cd | 3 | Grade codes |
- Heavy customers: customers 1–100 have 2,000 or more orders each. Other customers have about 18.
- Skewed status:
statusis DONE 90%, PAID 7%, CANCELED 3%. - Numeric string column:
ord_nois avarcharmade only of digits. - Independent columns: customer, status, amount, and region are generated with a hash function (splitmix64) and are not correlated. Individual values differ from the other DBs, but the distributions are the same.
| Table | Columns (tuple key first) |
|---|---|
customers | cust_id int64, cust_nm varchar(40), grade varchar(16), region varchar(16), join_dt timestamp |
orders | ord_id int64, cust_id int64, ord_no varchar(24), status varchar(16), ord_dt timestamp, amt int64 |
grade_cd | grade varchar(16) PRIMARY KEY, grade_nm varchar(32) |
| Index | Columns | Difference from other DBs |
|---|---|---|
| (tuple key) | customers.cust_id, orders.ord_id | No separate primary key index. The table is a B+ tree clustered on this key (tuple key) |
Primary key of grade_cd | grade | A string primary key, so it is a unique index beside a hidden tuple key. Rows are placed at the key's hash position |
orders_x1 | cust_id, ord_dt | |
orders_x2 | status, ord_dt | Other DBs use (status, ord_dt, ord_id). An index entry's value is already the tuple key (ord_id), so KDBS rejects the third column |
orders_x3 | ord_no | |
customers_x1 | grade |
All columns are NOT NULL. KDBS makes a column NOT NULL unless it is declared NULL. The generation script is db/kdbs/load.py, which runs once when the container first starts. After loading, statistics for the three tables are gathered (GATHER STATISTICS) and locked (LOCK STATISTICS) so that the join order is the same on every run.
Differences from other DBs
| Item | KDBS sandbox |
|---|---|
| Aliases | FROM orders AS o. An alias without AS is a syntax error |
| Date conditions | ord_dt is timestamp. Literals are '2025-09-01 00:00:00' (a date alone is rejected). No DATE '…' syntax |
| Type conversion | No implicit type conversion. Writing a number, as in ord_no = 2025…, is rejected before execution |
| Execution plan | The statement runs once more under ANALYZE to get opens, examined, matched, pages per step (Reading ANALYZE) |
| Buffers | Pages read by the step (pages, 8KB). The top SELECT row is the total for the whole statement |
| Starts / A-Rows | opens / matched |
| E-Rows | The per-step estimate used when choosing the join order (planned … est=). Empty for single-table statements |
| Hints | None. CREATE PLAN, which changes join order and access method, is an administrator statement and cannot run in the sandbox. The scenarios change steps through the shape of the statement |
| Query layer | Outer joins, UNION, scalar subqueries, expressions in the select list, and so on return results, but the execution plan table is empty (the reason is in the Raw tab) |
| Resource limits | 1 million rows held by sorts and the query layer (sort_max_rows), 3 million rows interpreted per statement (max_rows_touched), 15 seconds of execution |
| Account | sbx_run with the readonly role. Every run is BEGIN READ ONLY ISOLATION LEVEL REPEATABLE READ … ROLLBACK |
How to measure
- Buffers (pages) is the basis for comparison. All data (about 81,000 pages) is in the buffer pool, so execution time is almost entirely CPU time.
- KDBS secondary indexes are in a different order from the table. Each row found through an index often reads a different table page, so reading many rows through an index reads as many pages as rows. The whole table (
orders) is 24,097 pages. - The Trace tab shows
examined(rows filtered) andDB time(CPU and wait time) per step. Whenexaminedis much larger than A-Rows, many rows were read and discarded.
TRY · One row by tuple key
SELECT * FROM customers WHERE cust_id = 42
TRY · Recent orders of one customer via a secondary index
SELECT ord_id, ord_dt, amt
FROM orders
WHERE cust_id = 101
ORDER BY ord_dt DESC
LIMIT 5