磨砺技术珠矶,践行数据之道,追求卓越价值

回到上一级页面: PostgreSQL索引页

[作者:高健@博客园  mail: luckyjackgao@gmail.com ]

根据向网络牛人发问整理得到:

random_page_cost = 4
seq_page_cost = 1
cpu_tuple_cost =0.01
cpu_index_tuple_cost =0.005
cpu_operator_cost =0.0025

postgres=# select relpages, reltuples  from pg_class where relname = 'pg_proc';
 relpages | reltuples 
----------+----------- 
62        |      2490

postgres=# select relpages, reltuples from pg_class where relname = 'pg_proc_oid_index'; relpages | reltuples ----------+----------- 9 | 2490

我的执行计划:

postgres=# explain SELECT * FROM pg_proc where oid=1; 
QUERY PLAN                    
-----------------------------------------------------------------------------------  
 Index Scan using pg_proc_oid_index on pg_proc  (cost=0.00..8.27 rows=1 width=548)                       
   Index Cond: (oid = 1::oid) 
(2 rows)

8.27 是怎么来的呢?修改上述的各个参数观察结果的变化,可以得知:

cost = 2*random_page_cost + cpu_tuple_cost +cpu_index_tuple_cost + 100* cpu_operator_cost

其中 random_page_cost *2 ,是一个page 读用于index page, 另一个用于读 data page。

 

[作者:高健@博客园  mail: luckyjackgao@gmail.com ]

回到上一级页面: PostgreSQL索引页

磨砺技术珠矶,践行数据之道,追求卓越价值

相关文章:

  • 2021-10-12
  • 2022-01-24
  • 2022-12-23
  • 2022-12-23
  • 2021-07-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-23
  • 2021-06-14
相关资源
相似解决方案