CodeBlanks Logo Icon CodeBlanks

Cost

Read the cost of a plan.

Cost

EXPLAIN shows the cost of each step. A low cost means a fast query.

EXPLAIN SELECT * FROM products;
-- cost=0.00..15.20 rows=150

Cost and row estimate.

All columns are selected from products.

Cost — details

Cost units are relative. Used for comparison, not absolute time.

You compare two versions of the same query with EXPLAIN and pick the one with lower cost; a smaller number means the plan is estimated to be cheaper.

Practice Cost

See the cost of a query with EXPLAIN.

Starter code

query.sql
-- inspect cost
EXPLAIN

Sample solution

query.sql
EXPLAIN SELECT * FROM products;

Expected output

cost=0.00..15.20

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Cost: match the terms

Term Meaning
cost cost
low fast
high slow
relative comparison

2 cost

Question
____=maliyet
Answer
cost=maliyet

Explanation: Cost in EXPLAIN output is the plan's estimated cost; a lower value means faster.

3 What does a low cost mean?

  • A slow query
  • An error
  • A fast query Correct answer
  • No index

Explanation: A low cost means a fast query.

All lessons in Advanced