Common lab environment

The schema, data distribution, indexes, and execution plan measurement method shared by the PostgreSQL scenarios

The PostgreSQL scenarios run on the single schema in this document. The tables, columns, indexes, and data distribution match the Oracle environment. Run a scenario with the same number on both DBs to compare their 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. Insert order matches date order
grade_cd3Grade codes
  • Heavy customers: customers 1–100 have 2,000 or more orders each. The 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 come from a hash function (hashint8extended), so they are uncorrelated. It plays the role of Oracle's ORA_HASH. Individual values differ from Oracle, but the distribution is the same.
IndexColumns
customers_pkcust_id
customers_x1grade
orders_pkord_id
orders_x1cust_id, ord_dt
orders_x2status, ord_dt, ord_id
orders_x3ord_no

The creation script is db/postgres/init/01-schema-data.sql. It runs once when the container first creates the database.

Differences from Oracle

ItemPostgreSQL sandbox
Date columnsord_dt and join_dt are timestamp(0) (seconds). Same values as Oracle's DATE
StatisticsGathered once with VACUUM (ANALYZE, FREEZE) right after loading, with autovacuum off. Same execution plan for everyone
Execution planEXPLAIN (ANALYZE, BUFFERS, FORMAT JSON). Runs the statement once and counts actual rows and buffers per node
BuffersThe node's shared hit + read block count (8KB). Cumulative including child nodes, so it reads the same way as Oracle's Buffers
Starts / A-RowsActual Loops / Actual Rows × Loops. For repeated nodes the row count is a rounded average, so it can differ slightly
HintsNone. Instead, change planner settings such as SET LOCAL enable_hashjoin = off to force a different plan. A setting is valid only within that run (transaction)
Parallel queryOff (max_parallel_workers_per_gather = 0), so Starts and Buffers read like Oracle. Turn it on with SET LOCAL when needed
AccountThe run account sbx_run has only SELECT on the tune schema. Every transaction is read-only

Measurement method

  • Buffers is the basis of comparison. Execution time varies with cache state.
  • Warm run on screen runs once to warm the cache and shows the second result.
  • EXPLAIN ANALYZE builds the whole result. So even if you reduce "rows to fetch" to 20, the plan figures are for the whole result. To see the effect of stopping at the first few rows, use LIMIT in the SQL.
  • The Trace tab shows planning time, execution time, and shared buffer hits and reads.
-- Run with a changed planner setting: hash join is off only inside this block
SET LOCAL enable_hashjoin = off;
SELECT ...