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

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 to 100 each have 2,000 or more orders.
  • Skewed status values: status is DONE 90%, PAID 7%, CANCELED 3%.
  • Numeric string column: ord_no is a varchar(20) made of digits only (yyyyMMdd + 8-digit serial, e.g. 2025091501976001).
  • Independent columns: customer, status, amount, and region come from HASHBYTES hashes and are uncorrelated.
  • Character columns are varchar: comparing them with Unicode literals (N'…') or nvarchar parameters causes a type conversion (scenario 21).
IndexColumnsKind
customers_pkcust_idClustered (the table itself)
orders_pkord_idClustered (the table itself)
orders_x1cust_id, ord_dtNonclustered
orders_x2status, ord_dt, ord_idNonclustered
orders_x3ord_noNonclustered
customers_x1gradeNonclustered

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

ItemSQL Server sandbox
Table structureThe 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)
StatisticsGathered with FULLSCAN after loading, with auto update and auto create turned off. Everyone gets the same execution plan
Execution planThe actual execution plan from SET STATISTICS XML ON. The statement runs to completion, and executions, actual rows, and logical reads are counted per operator
BuffersThe operator's ActualLogicalReads (8KB pages) plus those of its child operators, as a cumulative value. Read the same way as in Oracle and PostgreSQL
HintsQuery 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 queryTurned off (database MAXDOP = 1). Turn it on with OPTION (MAXDOP 4) when needed
WarningsOptimizer warnings (PlanAffectingConvert type conversion, MemoryGrantWarning, etc.) appear at the top of the Raw tab
AccountThe 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)