OhMyCalc

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

  1. Enter the total number of rows in the table.
  2. Enter query selectivity as a percentage.
  3. Select whether an index exists.
  4. Click Calculate to see rows scanned and I/O cost.

Casi d'Uso

Formula

With index: rows scanned = table rows × selectivity. Without index: full table scan. I/O cost = log2(N) + matched rows (with index).

Domande Frequenti

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.