Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cost of a query in PostgreSQL

Tags:

postgresql

When 'Explain' is used along with the select statement in PostgreSQL, it gives the query plan as shown below

Seq Scan on employee  (cost=0.00..12.13 rows=1 width=438)
  Filter: ((lastname)::text = 'John'::text)

I couldn't understand what does '0.00..12.13' mean? Can anyone explain?

like image 816
ben Avatar asked Nov 05 '25 16:11

ben


1 Answers

First number is startup cost. Second is estimated total cost.

According to documentation, the costs are measured in arbitrary units determined by the planner's cost parameters. Traditional practice is to measure the costs in units of disk page fetches; that is, seq_page_cost is conventionally set to 1.0 and the other cost parameters are set relative to that.

like image 184
mvp Avatar answered Nov 09 '25 10:11

mvp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!