patternsqlMinor
Is Postgres ignoring my function cost annotation?
Viewed 0 times
postgresfunctionignoringcostannotation
Problem
Why does this:
return this:
and not a cost of 777?
create or replace function dummy() returns double precision as $
SELECT random() $
LANGUAGE SQL
COST 777;
explain select dummy();return this:
Result (cost=0.00..0.01 rows=1 width=0)and not a cost of 777?
Solution
I believe the costs refer to different units of measurement. The
For function cost details, see http://www.postgresql.org/docs/current/static/sql-createfunction.html
For
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 http://www.postgresql.org/docs/current/static/sql-createfunction.html
For
EXPLAIN plan costs, see http://www.postgresql.org/docs/current/static/using-explain.htmlContext
StackExchange Database Administrators Q#53334, answer score: 2
Revisions (0)
No revisions yet.