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

TableRowsDescription
customers100,000Customers. Grade VIP 1%, GOLD 9%, NORMAL 90%. 5 regions at 20% each
orders2,000,000Orders. 2,000 per day from 2023-01-01 to 2025-09-26. ord_id order matches date order
grade_cd3Grade codes
  • Heavy customers: customers 1–100 have 2,000 or more orders each. Other customers have about 18.
  • Skewed status: status is DONE 90%, PAID 7%, CANCELED 3%.
  • Numeric string column: ord_no is a varchar made 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.
TableColumns (tuple key first)
customerscust_id int64, cust_nm varchar(40), grade varchar(16), region varchar(16), join_dt timestamp
ordersord_id int64, cust_id int64, ord_no varchar(24), status varchar(16), ord_dt timestamp, amt int64
grade_cdgrade varchar(16) PRIMARY KEY, grade_nm varchar(32)
IndexColumnsDifference from other DBs
(tuple key)customers.cust_id, orders.ord_idNo separate primary key index. The table is a B+ tree clustered on this key (tuple key)
Primary key of grade_cdgradeA string primary key, so it is a unique index beside a hidden tuple key. Rows are placed at the key's hash position
orders_x1cust_id, ord_dt
orders_x2status, ord_dtOther 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_x3ord_no
customers_x1grade

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

ItemKDBS sandbox
AliasesFROM orders AS o. An alias without AS is a syntax error
Date conditionsord_dt is timestamp. Literals are '2025-09-01 00:00:00' (a date alone is rejected). No DATE '…' syntax
Type conversionNo implicit type conversion. Writing a number, as in ord_no = 2025…, is rejected before execution
Execution planThe statement runs once more under ANALYZE to get opens, examined, matched, pages per step (Reading ANALYZE)
BuffersPages read by the step (pages, 8KB). The top SELECT row is the total for the whole statement
Starts / A-Rowsopens / matched
E-RowsThe per-step estimate used when choosing the join order (planned … est=). Empty for single-table statements
HintsNone. 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 layerOuter 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 limits1 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
Accountsbx_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) and DB time (CPU and wait time) per step. When examined is 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