Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why does this:

create or replace function dummy() returns double precision as $$
SELECT random() $$
COST 777;
explain select dummy();

return this:

Result  (cost=0.00..0.01 rows=1 width=0)

and not a cost of 777?

share|improve this question

I believe the costs refer to different units of measurement. The cost when used in functions is the estimated execution cost in units of cpu_operator_cost, whereas the EXPLAIN plan costs are units of disk page fetches (seq_page_cost).

For function cost details, see

For EXPLAIN plan costs, see

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.