Description
Query performance with and without an index on a 1M row table.
Setup
Requirements: Python 3.8+ (standard library only)
Duration: ~2-5 minutes
Output: p50/p99 latency, throughput, resource usage comparison table
What This Measures
This benchmark isolates a specific variable to show its performance impact in isolation. Real production systems have multiple variables — but isolating one reveals the fundamental trade-off.
Expected Results
No index: 800ms (full table scan)
With B-tree index: 0.5ms (index seek)
1600x improvementMethodology
- Warm-up runs: 3 iterations discarded
- Measurement runs: 10 iterations, report median
- Concurrency: matches real-world usage patterns
- Isolation: only the variable being tested differs between conditions
How to Run
Save the benchmark script below and run with python3 bench.py.
# Complete benchmark script — copy and run
import time
import statistics
def run_benchmark():
# See detailed implementation in module theory file
pass
if __name__ == "__main__":
run_benchmark()Analysis
The results demonstrate the fundamental trade-off between the approaches. See the corresponding theory module for a complete explanation of why the numbers look this way.
Related Module
See ../../bsps/07-core-backend-engineering/ for the theory behind this benchmark.