Index & Join Cost Estimator
System-R style cost estimates: sequential scan versus B+ tree index (clustered or not), and nested-loop, block nested-loop, hash and sort-merge joins — with page I/O and a simple CPU term.
About this tool
Compare selection access paths and equality joins using estimated page I/Os plus a configurable CPU weight. These are educational estimates, not measured times or database engine plans. Change an input to clear its result, then estimate again. Tabs and inputs survive navigation and reload.
Selection. N and P are rows and pages; selectivity is a fraction from 0 to 1. Unique equality assumes one matching row and disables selectivity. Sequential scan: P I/Os and N × CPU. Index height H includes the first leaf: index I/O = H−1 + max(1, ceil(matches / leaf keys)) + data reads. Clustered data reads = ceil(matches × P / N), capped at P; otherwise one read per match. CPU = (1.2 × matches + H) × weight. Disabled index settings are ignored.
Joins. R stays outer, S inner. Output ≈ rows R × rows S × selectivity. Page nested loops: Pᵣ + PᵣPₛ. Block loops: Pᵣ + ceil(Pᵣ/(B−2))Pₛ. An index on S uses H reads per outer row plus one per matching output row; additional range leaves are not modeled. Hash builds on the smaller relation, using B−2 build pages and uniform B−1-way partitions; each partition level adds two reads/writes of both relations. No key skew is simulated.
Sort and CPU. Materialized sorting starts with ceil(P/B) runs, merging B−1 at a time. Each pass costs 2P; sort-merge adds a scan of both sorted relations. No fusion of final sort and join, duplicate-group rescans or output writes. CPU is a heuristic operation weight: loops count comparisons, index loops count traversal and matches, hash counts twice the input rows, sorting counts n log₂ n per relation. Every join also counts output rows. The weight uses the same abstract units as one page I/O; it is not milliseconds.
Counts 1–10⁹, buffer 3–10⁹, height 1–8, CPU 0–10⁶. Floating-point estimates may be fractional or approximate at large cardinalities. No cache, histograms, parallelism or join-order search. The chart is optional. Formula references: Berkeley CS186 sorting and joins.
Raw inputs, including invalid or unfinished drafts, are saved locally up to 100000 serialized characters. Above this limit the previous saved copy is retained; download the inputs before reloading or leaving the page. Navigation within this app keeps the live draft. A reload restores the saved inputs and waits for Estimate. Small nonzero estimates and very large costs use scientific notation; these estimates are not exact counts.