Postgres 是否忽略了我的函数成本注释?

Jim*_*ker 6 postgresql functions postgresql-9.2

为什么会这样:

create or replace function dummy() returns double precision as $$
SELECT random() $$
LANGUAGE SQL
COST 777;
explain select dummy();
Run Code Online (Sandbox Code Playgroud)

返回这个:

Result  (cost=0.00..0.01 rows=1 width=0)
Run Code Online (Sandbox Code Playgroud)

而不是777的成本?

bma*_*bma 2

我相信成本是指不同的计量单位。函数中使用的when是以cpu_operator_costcost为单位的估计执行成本,而计划成本是以磁盘页获取 ( seq_page_cost ) 为单位。EXPLAIN

有关函数成本的详细信息,请参阅http://www.postgresql.org/docs/current/static/sql-createfunction.html

有关EXPLAIN计划成本,请参阅http://www.postgresql.org/docs/current/static/using-explain.html