Common lab environment
The schema, data distribution, indexes, and execution plan measurement method shared by the SQL Server scenarios
The SQL Server scenarios run on the single schema in this document. Tables, columns, indexes, and data distribution match the Oracle environment. A scenario with the same number can be run on all three DBs to compare execution plans.
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 to 100 each have 2,000 or more orders.
- Skewed status values:
statusis DONE 90%, PAID 7%, CANCELED 3%. - Numeric string column:
ord_nois avarchar(20)made of digits only (yyyyMMdd+ 8-digit serial, e.g.2025091501976001). - Independent columns: customer, status, amount, and region come from
HASHBYTEShashes and are uncorrelated. - Character columns are
varchar: comparing them with Unicode literals (N'…') ornvarcharparameters causes a type conversion (scenario 21).
| Index | Columns | Kind |
|---|---|---|
customers_pk | cust_id | Clustered (the table itself) |
orders_pk | ord_id | Clustered (the table itself) |
orders_x1 | cust_id, ord_dt | Nonclustered |
orders_x2 | status, ord_dt, ord_id | Nonclustered |
orders_x3 | ord_no | Nonclustered |
customers_x1 | grade | Nonclustered |
The creation script is db/mssql/init/01-schema-data.sql. db/mssql/entrypoint.sh runs it once when the container first starts.
Differences from Oracle
| Item | SQL Server sandbox |
|---|---|
| Table structure | The clustered index (PK) is the table. For rows found through a nonclustered index, the remaining columns are looked up again by PK (Key Lookup, shown as Clustered Index Seek in the execution plan) |
| Statistics | Gathered with FULLSCAN after loading, with auto update and auto create turned off. Everyone gets the same execution plan |
| Execution plan | The actual execution plan from SET STATISTICS XML ON. The statement runs to completion, and executions, actual rows, and logical reads are counted per operator |
| Buffers | The operator's ActualLogicalReads (8KB pages) plus those of its child operators, as a cumulative value. Read the same way as in Oracle and PostgreSQL |
| Hints | Query hints such as OPTION (LOOP JOIN) and OPTION (HASH JOIN) and table hints such as WITH (INDEX(orders_x2)) are written inside the SQL |
| Parallel query | Turned off (database MAXDOP = 1). Turn it on with OPTION (MAXDOP 4) when needed |
| Warnings | Optimizer warnings (PlanAffectingConvert type conversion, MemoryGrantWarning, etc.) appear at the top of the Raw tab |
| Account | The run login sbx_run has only SELECT and SHOWPLAN on the dbo schema. Every run happens inside a transaction and is rolled back |
Measurement method
- Buffers (logical reads) is the basis of comparison.
- The actual execution plan appears after the full result is produced. Even if "rows to fetch" is reduced, the plan figures are for the full result; the effect of stopping at the first few rows is shown with
TOP. - The Trace tab shows compile time, CPU time, elapsed time, and memory grant.
-- Query hint: NL join for this statement only
SELECT ... FROM orders o JOIN customers c ON c.cust_id = o.cust_id
OPTION (LOOP JOIN)