Database Indexing Benchmark

Comparing query performance with and without indexes

Environment Information

OS: Windows_NT 10.0.26200 (x64) CPU: 12th Gen Intel(R) Core(TM) i7-12700 (20 cores) RAM: 31.7 GB

Test Configuration

Virtual Users: 10 Duration: 30s / scenario Sample Data: 10k products, 100k Users, 1M Trans.

POSTGRES Improvement

-3.1%
Average p95 latency reduction with indexes

MYSQL Improvement

31.0%
Average p95 latency reduction with indexes

Scenarios Tested

9
Different query patterns benchmarked

Databases Compared

2
POSTGRES, MYSQL

P95 Response Time Comparison (ms)

Internal Database Query Time (p95 ms)

Throughput Comparison (requests/sec)

Latency Percentiles by Database

POSTGRES - All Percentiles (With Index)

MYSQL - All Percentiles (With Index)

Per-Scenario Improvement (HTTP)

Scenario SQL Query POSTGRES No Index (ms)POSTGRES With Index (ms)ImprovementMYSQL No Index (ms)MYSQL With Index (ms)Improvement
aggregation SELECT COUNT(*) as count FROM products WHERE category = ? 15.3812.62+17.9%17.4415.75+9.7%
composite-filter SELECT * FROM users WHERE country = ? AND status = ? LIMIT 100 12.2717.78-44.9%22.3119.78+11.3%
join-query SELECT t.*, u.name as user_name, p.name as product_name FROM transactions t JOIN users u ON t.user_id = u.id JOIN products p ON t.product_id = p.id WHERE t.user_id = ? ORDER BY t.created_at DESC LIMIT 50 44.9844.67+0.7%16.3315.39+5.8%
pagination SELECT * FROM transactions ORDER BY id LIMIT ? OFFSET ? 15.6017.16-10.0%17.5216.83+3.9%
point-lookup SELECT * FROM users WHERE email = ? 10.4211.79-13.2%14.6110.93+25.1%
prefix-search SELECT * FROM users WHERE name LIKE ? LIMIT 50 19.6717.27+12.2%24.2716.95+30.1%
range-query SELECT * FROM users WHERE created_at BETWEEN ? AND ? LIMIT 100 14.0618.17-29.2%59.2221.96+62.9%
sorting SELECT * FROM products ORDER BY price DESC LIMIT 20 13.1114.04-7.1%19.5413.34+31.8%
status-filter SELECT * FROM transactions WHERE status = ? AND created_at BETWEEN ? AND ? ORDER BY created_at DESC LIMIT 100 34.7718.84+45.8%1560.9922.82+98.5%

Index Impact by Scenario