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
| 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. Insert order matches date order |
grade_cd | 3 | Grade codes |
- Heavy customers: customers 1–100 have 2,000 or more orders each. The 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 come from a hash function (
hashint8extended), so they are uncorrelated. It plays the role of Oracle'sORA_HASH. Individual values differ from Oracle, but the distribution is the same.
| Index | Columns |
|---|---|
customers_pk | cust_id |
customers_x1 | grade |
orders_pk | ord_id |
orders_x1 | cust_id, ord_dt |
orders_x2 | status, ord_dt, ord_id |
orders_x3 | ord_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
| Item | PostgreSQL sandbox |
|---|---|
| Date columns | ord_dt and join_dt are timestamp(0) (seconds). Same values as Oracle's DATE |
| Statistics | Gathered once with VACUUM (ANALYZE, FREEZE) right after loading, with autovacuum off. Same execution plan for everyone |
| Execution plan | EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON). Runs the statement once and counts actual rows and buffers per node |
| Buffers | The node's shared hit + read block count (8KB). Cumulative including child nodes, so it reads the same way as Oracle's Buffers |
| Starts / A-Rows | Actual Loops / Actual Rows × Loops. For repeated nodes the row count is a rounded average, so it can differ slightly |
| Hints | None. 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 query | Off (max_parallel_workers_per_gather = 0), so Starts and Buffers read like Oracle. Turn it on with SET LOCAL when needed |
| Account | The 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 ANALYZEbuilds 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, useLIMITin 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 ...