Database Query Cost Calculator
Estimate database query cost in terms of rows scanned and I/O units. Understand the impact of indexes on query performance.
How to Use the Query Cost Calculator
- Enter the total number of rows in the table.
- Enter query selectivity as a percentage.
- Select whether an index exists.
- Click Calculate to see rows scanned and I/O cost.
Casos de Uso
- •Diagnosing slow database queries.
- •Justifying index creation for large tables.
- •Teaching database query optimization concepts.
- •Estimating query performance after schema changes.
Fórmula
With index: rows scanned = table rows × selectivity. Without index: full table scan. I/O cost = log2(N) + matched rows (with index).
Preguntas Frecuentes
What is query selectivity?
Selectivity is the fraction of rows matching a query condition. 1% selectivity on 1M rows = 10,000 rows.
When does a database use an index?
The query optimizer uses an index when selectivity is low (few rows match), making the index more efficient than a full scan.
What is a covering index?
A covering index includes all columns needed by a query, avoiding a second lookup into the main table.