作者简介
译者简介
顺序扫描的代价估计
test=# CREATE TABLE t_test AS
SELECT id AS many, id % 2 AS few
FROM generate_series(1, 10000000) AS id;
SELECT 10000000
test=# ANALYZE;
ANALYZE
复制
test=# SET max_parallel_workers_per_gather TO 0;
SET
test=# explain SELECT count(*) FROM t_test;
QUERY PLAN
------------------------------------------------------------------------
Aggregate (cost=169248.60..169248.61 rows=1 width=8)
-> Seq Scan on t_test (cost=0.00..144248.48 rows=10000048 width=0)
(2 rows)
复制
test=# SELECT pg_relation_size('t_test') AS size,
pg_relation_size('t_test') 8192 AS blocks;
size | blocks
-----------+--------
362479616 | 44248
(1 row)
复制
test=# SELECT current_setting('seq_page_cost')::numeric * 44248
+ current_setting('cpu_tuple_cost')::numeric * 10000000
+ current_setting('cpu_operator_cost')::numeric * 10000000;
?column?
-------------
169248.0000
(1 row)
复制
并行顺序扫描估计
test=# SET max_parallel_workers_per_gather TO default;
SET
test=# explain SELECT count(*) FROM t_test;
QUERY PLAN
------------------------------------------------------------------------------------
Finalize Aggregate (cost=97331.80..97331.81 rows=1 width=8)
-> Gather (cost=97331.58..97331.79 rows=2 width=8)
Workers Planned: 2
-> Partial Aggregate (cost=96331.58..96331.59 rows=1 width=8)
-> Parallel Seq Scan on t_test (cost=0.00..85914.87 rows=4166687 width=0)
(5 rows)
复制
estimate = estimated_rows (number_of_cores + (1 – leader_contribution * number_of_cores)
复制

其他并行操作
原文地址
最后修改时间:2020-02-28 13:50:54
文章转载自PostgreSQL中文社区,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
外国CTO也感兴趣的开源数据库项目——openHalo
小满未满、
425次阅读
2025-04-21 16:58:09
9.9 分高危漏洞,尽快升级到 pgAdmin 4 v9.2 进行修复
严少安
355次阅读
2025-04-11 10:43:23
3月“墨力原创作者计划”获奖名单公布
墨天轮编辑部
332次阅读
2025-04-15 14:48:05
openHalo问世,全球首款基于PostgreSQL兼容MySQL协议的国产开源数据库
严少安
301次阅读
2025-04-07 12:14:29
postgresql+patroni+etcd高可用安装
necessary
167次阅读
2025-03-28 10:11:23
从 Oracle 到 PostgreSQL迁移成本评估揭秘
梧桐
152次阅读
2025-03-27 17:21:42
手把手教你在 openKylin 上部署 IvorySQL 4.4
严少安
151次阅读
2025-03-27 20:41:28
转发有奖 | PostgreSQL 16 PGCM高级认证课程直播班招生中!
墨天轮小教习
147次阅读
2025-04-14 15:58:34
墨天轮PostgreSQL认证证书快递已发(2025年3月批)
墨天轮小教习
128次阅读
2025-04-03 11:43:25
SQL 优化之 OR 子句改写
xiongcc
93次阅读
2025-04-21 00:08:06