Free · No sign-up Client-side

DATABASES & SQL · FREE DEVELOPER TOOL

SQL Query Cost Estimator

DATABASES & SQL · FREE DEVELOPER TOOL October 2026 11 min read

Estimates a SQL query’s planner-style cost from sequential and random page reads, CPU tuple work and startup overhead. Free, instant and entirely client-side.

Planner cost units are relative, not milliseconds.

Estimates a SQL query’s planner-style cost from sequential and random page reads, CPU tuple work and startup overhead.

DATABASES & SQLClient-sideWorked examples2026
Typical page size
8 KB
Source: PostgreSQL / SQL Server
Healthy index hit ratio
70–90%
Source: Workload-dependent
Connections per CPU core
10–20
Source: Pooling guidance
Replica lag target
≤ 1 s
Source: Async replication

Quick answer

Estimates a SQL query’s planner-style cost from sequential and random page reads, CPU tuple work and startup overhead. The calculator applies cost = startup + seq_pages × seq_cost + random_pages × random_cost + rows_examined × cpu_tuple_cost and shows every intermediate value.

On this page
  1. 1Quick Answer
  2. 2Interactive Calculator
  3. 3SQL Query Cost Estimator: Calculation Breakdown
  4. 4Key Takeaways
  5. 5Databases & SQL Reference Numbers
  6. 6Implementation Approaches
  7. 7Reference Tables
  8. 8Formulas & How to Use
  9. 9Worked Examples
  10. 10Advanced Guide: SQL Query Cost Estimator
  11. 11Language Playbooks
  12. 12Glossary
  13. 13Mistakes & Pro Tips
  14. 14Use Cases
  15. 15Related Calculators
  16. 16Long-Tail Answers
  17. 17FAQs (29)
  18. 18References

Interactive Calculator

Enter a value — every result updates instantly, in your browser. Free forever, no sign-up.

Private Exact math

SQL Query Cost Estimator

Every input is evaluated locally in your browser with deterministic arithmetic.

Runs in your browser
Sequential pages read Heap or index pages read in sequential order.Random pages read Pages fetched by random I/O, such as index lookups.Rows examined Rows the executor must inspect.Sequential page cost Planner cost unit per sequential page.Random page cost Planner cost unit per random page.CPU cost per row Planner cost unit per examined row.Startup cost Fixed planning and executor startup cost.Milliseconds per cost unit Calibration from observed query latency.

Live result

2,330.5 cost units

57.1% of the estimated cost is I/O.

CPU significantPlanner-style cost model

Estimated latency

46.61 milliseconds

Startup cost

0.5

Sequential I/O cost

1,250

Random I/O cost

80

SQL Query Cost Estimator: Calculation Breakdown

Every input, intermediate value and result row behind the estimate.

Calculated values and supporting details
Estimated latency
46.61 milliseconds

Calibrated at 0.02 ms per cost unit.

Startup cost
0.5
Sequential I/O cost
1,250
Random I/O cost
80
CPU tuple cost
1,000
I/O share of total
57.1%
Cost per returned row
0.0233

Assumes every examined row is returned.

Step-by-step calculation

  1. 1Sequential I/O: 1,250 pages × 1 = 1,250.
  2. 2Random I/O: 20 pages × 4 = 80.
  3. 3CPU: 100,000 rows × 0.01 = 1,000.
  4. 4Total: 0.5 + 1,250 + 80 + 1,000 = 2,330.5 cost units.

Key Takeaways

The 30-second version — the exact answers Google loves to feature.

  • 1Planner cost units are relative, not milliseconds.
  • 2Sequential page cost is typically 1.0; random page cost is often 4.0.
  • 3Formula: cost = startup + seq_pages × seq_cost + random_pages × random_cost + rows_examined × cpu_tuple_cost
  • 4Default scenario: 2,330.5 cost units

Databases & SQL Reference Numbers

Useful benchmarks to sanity-check the output before you commit to a decision.

Typical page size
8 KB
Source: PostgreSQL / SQL Server
Healthy index hit ratio
70–90%
Source: Workload-dependent
Connections per CPU core
10–20
Source: Pooling guidance
Replica lag target
≤ 1 s
Source: Async replication
Headroom for storage growth
3×
Source: Capacity planning
Client-side calculation
100%
Source: No data uploaded

Implementation Approaches

Three practical ways teams use sql query cost estimator, with the precision and safeguards each one needs.

Recommended

Plan with measured statistics

Best for: Production changes where the query plan matters

  • Method: Collect row counts, average row width, index hit ratios and buffer-pool size, then run the calculator with the real values.
  • Precision: Use table statistics refreshed within the last day and separate hot from cold data.
  • Safeguards: Confirm the estimate with EXPLAIN (ANALYZE) on a staging copy before changing indexes or pool sizes.

Design-time sizing

Best for: New schemas, migrations and capacity proposals

  • Method: Start from expected rows and column widths, add index and backup overhead, then model 12, 36 and 60 months of growth.
  • Precision: Express assumptions as ranges and keep the growth rate visible.
  • Safeguards: Revisit after the first month of real data; early growth is rarely linear.

Incident triage

Best for: Latency spikes, pool exhaustion and replica lag

  • Method: Compare current latency, active connections and lag against the baseline to identify which component moved first.
  • Precision: Use p95 and p99 rather than averages, with the same measurement window.
  • Safeguards: Correlate with application deploys, traffic changes and maintenance jobs before changing configuration.

Quick Reference Tables

Widths, ranges, boundary values and language types — the lookup tables you will come back to.

Query cost inputs

InputTypical source
Sequential pagesEXPLAIN buffers or pg_statio_user_tables
Random pagesIndex scans and bitmap heap fetches
CPU tuple costpostgresql.conf cpu_tuple_cost
Startup costEXPLAIN top line

Database sizing quick reference

ItemTypical valueWhy it matters
Page size8 KB (PostgreSQL), 8 KB (SQL Server), 16 KB (MySQL InnoDB)Rows per page drives I/O and index fan-out
Row header23–24 bytesAdds up quickly on narrow tables
Index pointer6–8 bytesIncluded in every B-tree entry
Default fill factor90–100%Lower values leave room for updates
Backup compression2:1 to 5:1Depends on data entropy
Replica lag alert> 5 s or > 30 sMatch the business tolerance

Formulas & How to Use This Calculator

Core relationship

cost = startup + seq_pages × seq_cost + random_pages × random_cost + rows_examined × cpu_tuple_cost

Unit convention

Inputs are sequential pages read, random pages read, rows examined, sequential page cost, random page cost, cpu cost per row, startup cost, milliseconds per cost unit. Keep each unit consistent with the result rows; convert before comparing estimates that use different units or time windows.

Validation

1. Reproduce the headline from the displayed rows. 2. Compare the result with a measured, billed or benchmarked value. 3. Re-run with a boundary input and with a scaled input. 4. Record the assumptions, source and date next to the result.

How to use — step by step

  1. Open the SQL Query Cost Estimator and review the input defaults.
  2. Replace sequential pages read with your measured or planned value.
  3. Set random pages read (Pages fetched by random I/O, such as index lookups.).
  4. Set rows examined (Rows the executor must inspect.).
  5. Set sequential page cost (Planner cost unit per sequential page.).
  6. Read the headline result and compare it with the supporting rows in the breakdown.
  7. Test one boundary value and one scaled value to understand the sensitivity.
  8. Copy or record the result together with the units and assumptions used.

Worked Examples

Real numbers and raw bits, fully worked — copy the pattern for your own code or protocol.

Default scenario

Inputs

Sequential pages read = 1250; Random pages read = 20; Rows examined = 100000; Sequential page cost = 1.0; Random page cost = 4.0

Math

cost = startup + seq_pages × seq_cost + random_pages × random_cost + rows_examined × cpu_tuple_cost

Result

2,330.5 cost units · Estimated latency: 46.61 milliseconds · Startup cost: 0.5 · Sequential I/O cost: 1,250

Scaled scenario

Inputs

Sequential pages read = 2500; Random pages read = 30; Rows examined = 100000; Sequential page cost = 1.0; Random page cost = 4.0

Math

cost = startup + seq_pages × seq_cost + random_pages × random_cost + rows_examined × cpu_tuple_cost

Result

3,620.5 cost units · Estimated latency: 72.41 milliseconds · Startup cost: 0.5 · Sequential I/O cost: 2,500

Advanced Guide: SQL Query Cost Estimator

Beyond the calculator — how to use sql query cost estimator in real engineering, capacity and review decisions.

What the SQL Query Cost Estimator measures

Estimates a SQL query’s planner-style cost from sequential and random page reads, CPU tuple work and startup overhead. It turns ordinary project, infrastructure or runtime inputs into a visible number you can defend in a design review. The calculator is deliberately transparent: the result is derived from cost = startup + seq_pages × seq_cost + random_pages × random_cost + rows_examined × cpu_tuple_cost rather than from an opaque benchmark, so you can change one assumption and immediately see how the answer moves.

The formula and its units

The core relationship is cost = startup + seq_pages × seq_cost + random_pages × random_cost + rows_examined × cpu_tuple_cost. Every field is labelled with its unit and expected range next to the input, and the breakdown repeats the intermediate values so a reviewer can verify the arithmetic. When you compare two results, make sure both were computed with the same units and the same time window; most apparent differences in databases & sql estimates are really unit or scope mismatches.

A worked check with the default inputs

With the default inputs (Sequential pages read = 1250; Random pages read = 20; Rows examined = 100000; Sequential page cost = 1.0; Random page cost = 4.0), the calculator reports 2,330.5 cost units. Change Sequential pages read and the headline moves to 3,620.5 cost units. That sensitivity is useful: if a small input change produces a large output change, the assumption deserves a source or a range rather than a single guess.

Inputs, assumptions and defaults

The inputs are Sequential pages read (Heap or index pages read in sequential order.); Random pages read (Pages fetched by random I/O, such as index lookups.); Rows examined (Rows the executor must inspect.); Sequential page cost (Planner cost unit per sequential page.); Random page cost (Planner cost unit per random page.); CPU cost per row (Planner cost unit per examined row.); Startup cost (Fixed planning and executor startup cost.); Milliseconds per cost unit (Calibration from observed query latency.). Defaults are realistic starting points, not recommendations for your system. Replace them with measured values wherever possible: production metrics, billing exports, compiler sizeof output, provider documentation or historical project data. Keep the assumptions beside the result so the estimate can be reproduced later.

Reading a low or high result

A low result usually means small scale, generous headroom or optimistic assumptions; a high result means the opposite. Neither is automatically good or bad. Ask which input dominates the change, then compare the result with a second method such as a benchmark, a bill, a query plan or a pilot. Agreement between two independent methods is much stronger evidence than a single formula.

Common mistakes in databases & sql

Comparing cost units across database engines; each planner has its own scale. Forgetting that cached pages are much cheaper than disk reads. Document the units, the measurement window and the scope, and re-run the calculation when the workload or architecture changes.

How to validate the result

Validate with three checks: reproduce the headline from the displayed rows, compare the estimate with a measured production value, and test a boundary case (zero, one, the maximum or a doubled input). If the three checks disagree, the model or the input is wrong. Record the validation date and the data source so the next reviewer can repeat it.

Where this fits in Databases & SQL

This tool supports query cost, table and index size, connection pooling, replication, backups, partitioning and sharding. Use it during design, capacity review, incident follow-up or cost planning. Pair it with the related calculators to cover adjacent assumptions, and keep the output with the design decision so future changes can be compared against a known baseline.

Limitations and precision

No estimate is more accurate than its inputs. The calculator assumes steady-state behavior, consistent units and the defaults described in the field help. Real systems have bursty traffic, fragmentation, retries, background jobs and measurement error. Where the result informs a commitment or a budget, add a range and a contingency rather than treating the headline as a guarantee.

Related calculations to run next

The most useful companion tools are Index Size Estimator, Database Index Selectivity Calculator, Query Latency Calculator, Query Throughput Calculator. Together they cover the neighbouring assumptions — for example scale, overhead, failure headroom and cost — so you can present a complete estimate rather than a single isolated number.

Language & Platform Playbooks

The same bit pattern behaves differently in every language. Here is how to adapt the conversion safely.

PostgreSQL

Use EXPLAIN (ANALYZE, BUFFERS) to validate query cost, pg_total_relation_size for table and index size, and pg_stat_activity plus pgBouncer metrics to size pools. For sql query cost estimator, use the same units and time window described in the calculator so the result lines up with your platform data.

MySQL / InnoDB

Check EXPLAIN ANALYZE, information_schema.tables and innodb_buffer_pool_size. Keep the pool well below the server’s available RAM and monitor InnoDB row locks. For sql query cost estimator, use the same units and time window described in the calculator so the result lines up with your platform data.

SQL Server

Compare estimated and actual execution plans, inspect sys.dm_db_index_usage_stats, and size the buffer pool and max worker threads from measured workload. For sql query cost estimator, use the same units and time window described in the calculator so the result lines up with your platform data.

Cloud managed databases

Use the provider’s storage, IOPS and replica-lag metrics, and remember that backup size, retention and cross-region copies are billed separately. For sql query cost estimator, use the same units and time window described in the calculator so the result lines up with your platform data.

Glossary: Key Terms Explained

Page
The fixed-size block a database reads and writes, usually 8–16 KB.
Selectivity
The fraction of rows an index or predicate is expected to match.
Fill factor
The percentage of each page filled with data, leaving room for updates.
Replica lag
How far a read replica trails the primary in time or applied transactions.
Cardinality
The number of distinct values in a column or index.

Common Mistakes & Pro Tips

Mistakes that break conversions

  • Comparing cost units across database engines; each planner has its own scale.
  • Forgetting that cached pages are much cheaper than disk reads.
  • Mixing units or time windows when comparing two sql query cost estimator results.
  • Treating the default values as a recommendation instead of a starting point.
  • Reporting a single number without the assumptions, range or measurement date behind it.

Pro tips for production code

  • Calibrate milliseconds per cost unit on the same hardware and workload before quoting latency.
  • Measure the dominant input before refining the model; the largest uncertainty deserves the most attention.
  • Keep a short record of the inputs, result and date so future comparisons are meaningful.
  • Validate the estimate with a second method — a benchmark, a bill or production telemetry.
  • Pair this result with the related calculators (Index Size Estimator, Database Index Selectivity Calculator, Query Latency Calculator) for a complete picture.

Who Should Use This Calculator?

  • ▸ Query plan comparison before adding an index.
  • ▸ Explaining why a plan changed after a statistics refresh.
  • ▸ Capacity review: turn sequential pages read into a defensible planning number.
  • ▸ Design review: compare two architectures or configurations with the same assumptions.
  • ▸ Incident follow-up: quantify the gap between the estimate and observed behaviour.

Related Programming Calculators

Keep going — every tool below links directly into this workflow.

People Also Search For

Tap a long-tail question to jump to the matching FAQ answer.

Frequently Asked Questions (29)

Long-tail answers: each question targets a real Google search about sql query cost estimator — click to expand.

Showing 29 of 29 answers.

Is SQL query cost measured in milliseconds?
No. PostgreSQL cost units are arbitrary planner units. Multiplying by a calibration factor, as this calculator does, gives a rough latency estimate, but only EXPLAIN (ANALYZE) with real buffers and hardware measures actual time.
What does the SQL Query Cost Estimator calculate?
Estimates a SQL query’s planner-style cost from sequential and random page reads, CPU tuple work and startup overhead. The output includes the headline value, the intermediate rows and the formula, so you can audit the result rather than accepting a black-box number.
What formula does the SQL Query Cost Estimator use?
It uses cost = startup + seq_pages × seq_cost + random_pages × random_cost + rows_examined × cpu_tuple_cost. The calculator evaluates the formula with the values shown in the input panel and displays each intermediate term in the breakdown.
What should I enter for sequential pages read?
Heap or index pages read in sequential order. The default is 1250; replace it with a measured value whenever one is available, and keep the same unit for every comparison.
What should I enter for random pages read?
Pages fetched by random I/O, such as index lookups. The default is 20; replace it with a measured value whenever one is available, and keep the same unit for every comparison.
What should I enter for rows examined?
Rows the executor must inspect. The default is 100000; replace it with a measured value whenever one is available, and keep the same unit for every comparison.
What should I enter for sequential page cost?
Planner cost unit per sequential page. The default is 1.0; replace it with a measured value whenever one is available, and keep the same unit for every comparison.
What should I enter for random page cost?
Planner cost unit per random page. The default is 4.0; replace it with a measured value whenever one is available, and keep the same unit for every comparison.
What should I enter for cpu cost per row?
Planner cost unit per examined row. The default is 0.01; replace it with a measured value whenever one is available, and keep the same unit for every comparison.
What should I enter for startup cost?
Fixed planning and executor startup cost. The default is 0.5; replace it with a measured value whenever one is available, and keep the same unit for every comparison.
What should I enter for milliseconds per cost unit?
Calibration from observed query latency. The default is 0.02; replace it with a measured value whenever one is available, and keep the same unit for every comparison.
How do I interpret the SQL Query Cost Estimator result?
The headline is 2,330.5 cost units. 57.1% of the estimated cost is I/O. A single number is less useful than the trend and the assumptions behind it.
What units does the SQL Query Cost Estimator use?
The inputs are Sequential pages read, Random pages read, Rows examined, Sequential page cost, Random page cost, CPU cost per row, Startup cost, Milliseconds per cost unit. Units are shown on every field and repeated in the result rows. Do not mix decimal and binary units or seconds and milliseconds without converting first.
What are common mistakes when calculating sql query cost estimator?
Comparing cost units across database engines; each planner has its own scale. Forgetting that cached pages are much cheaper than disk reads. Re-run the calculation whenever the workload, architecture or pricing changes.
When should I use the SQL Query Cost Estimator?
Query plan comparison before adding an index. Explaining why a plan changed after a statistics refresh. It is a client-side planning tool, not a substitute for production monitoring or a benchmark.
How can I validate the SQL Query Cost Estimator result?
Reproduce the headline from the displayed rows, compare it with a measured or billed value, and test a boundary input such as zero, one or double the normal value. If the checks disagree, correct the input or the model before using the result.
What is a worked example of the SQL Query Cost Estimator?
For Sequential pages read = 1250; Random pages read = 20; Rows examined = 100000; Sequential page cost = 1.0; Random page cost = 4.0, the result is 2,330.5 cost units (Estimated latency: 46.61 milliseconds; Startup cost: 0.5).
What related calculators should I use with the SQL Query Cost Estimator?
Use Index Size Estimator, Database Index Selectivity Calculator, Query Latency Calculator, Query Throughput Calculator to cover the adjacent assumptions. Running several related estimates is more reliable than over-tuning one number.
Is the SQL Query Cost Estimator free and private?
Yes. The calculator runs entirely in your browser, requires no sign-up and sends no inputs to a server. That makes it safe for approximate capacity planning, although production secrets and customer data should never be pasted into any web page.
Can I use the SQL Query Cost Estimator for production planning?
Use it as a first-pass model and confirm the result with production measurements, provider documentation or a staging benchmark. Add headroom for uncertainty, and record the date and data source so the estimate can be reviewed later.
How sensitive is the SQL Query Cost Estimator to sequential pages read?
With the default value the result is 2,330.5 cost units; when sequential pages read is changed to 2500, the result becomes 3,620.5 cost units. Use this comparison to identify which input deserves the most careful measurement.
How accurate is a database size estimate?
A size estimate is accurate to roughly ±20–30% when row width, index count and fill factor are known. Variable-length columns, TOAST/overflow storage, bloat and page fragmentation add uncertainty, so confirm with the database’s own size functions after loading real data.
Should I use decimal or binary units for database storage?
Database engines usually report binary units (KiB, MiB, GiB), while cloud bills often use decimal GB. This calculator shows binary units by default; convert with 1 GiB = 1.074 GB when comparing with provider pricing.
Why does the estimated query cost differ from EXPLAIN?
PostgreSQL cost units are planner-specific and assume sequential page cost 1.0 and random page cost 4.0 by default. Your server may use different settings, statistics, caching and parallelism, so treat the estimate as a relative comparison and confirm with EXPLAIN (ANALYZE, BUFFERS).
What does a typical SQL Query Cost Estimator output look like?
The default scenario shows 2,330.5 cost units with rows for estimated latency, startup cost, sequential i/o cost. The exact wording of each row is shown in the technical breakdown above.
How precise is the SQL Query Cost Estimator?
The arithmetic is exact for the values entered, but the result is only as good as the inputs. Engineering estimates typically carry ±10–30% uncertainty, and capacity models can be further off when traffic is bursty. Report a range and the main assumptions rather than a single deceptively precise number.
Does the SQL Query Cost Estimator include overhead?
It includes the overhead represented by its input fields: sequential pages read, random pages read, rows examined, sequential page cost, random page cost, cpu cost per row, startup cost, milliseconds per cost unit. If your system has additional overhead — retries, replication, fragmentation, taxes or contingency — add it explicitly and document the adjustment.
How often should I re-run the SQL Query Cost Estimator?
Re-run it when the workload changes materially, when a provider or platform changes its limits or pricing, and at least once per planning cycle. Keep each result with the date and inputs so you can compare the trend instead of only the latest snapshot.
What is the best first step after using the SQL Query Cost Estimator?
Write down the three assumptions that most affect the result, then verify the largest one with a measurement. For databases & sql, that usually means checking a production metric, a bill or a documented limit before changing configuration.

Resources & Authoritative References

Further reading

Authoritative sources

Was this calculator helpful?

Last updated: October 2026 · Free forever · No sign-up · Part of Programming Calculators at Atlascalcs.com · All math runs in your browser