一、测试脚本
testdb=# explain
testdb-# select * from (
testdb(# select t_dwxx.dwmc,t_grxx.grbh,t_grxx.xm,t_jfxx.ny,t_jfxx.je
testdb(# from t_dwxx inner join t_grxx on t_dwxx.dwbh = t_grxx.dwbh
testdb(# inner join t_jfxx on t_grxx.grbh = t_jfxx.grbh
testdb(# where t_dwxx.dwbh IN ('1001')
testdb(# union all
testdb(# select t_dwxx.dwmc,t_grxx.grbh,t_grxx.xm,t_jfxx.ny,t_jfxx.je
testdb(# from t_dwxx inner join t_grxx on t_dwxx.dwbh = t_grxx.dwbh
testdb(# inner join t_jfxx on t_grxx.grbh = t_jfxx.grbh
testdb(# where t_dwxx.dwbh IN ('1002')
testdb(# ) as ret
testdb-# order by ret.grbh
testdb-# limit 4;
QUERY PLAN
------------------------------------------------------------------------------------------------------
Limit (cost=96.80..96.81 rows=4 width=360)
-> Sort (cost=96.80..96.83 rows=14 width=360)
Sort Key: t_grxx.grbh
-> Append (cost=16.15..96.59 rows=14 width=360)
-> Nested Loop (cost=16.15..48.19 rows=7 width=360)
-> Seq Scan on t_dwxx (cost=0.00..12.00 rows=1 width=256)
Filter: ((dwbh)::text = '1001'::text)
-> Hash Join (cost=16.15..36.12 rows=7 width=180)
Hash Cond: ((t_jfxx.grbh)::text = (t_grxx.grbh)::text)
-> Seq Scan on t_jfxx (cost=0.00..17.20 rows=720 width=84)
-> Hash (cost=16.12..16.12 rows=2 width=134)
-> Seq Scan on t_grxx (cost=0.00..16.12 rows=2 width=134)
Filter: ((dwbh)::text = '1001'::text)
-> Nested Loop (cost=16.15..48.19 rows=7 width=360)
-> Seq Scan on t_dwxx t_dwxx_1 (cost=0.00..12.00 rows=1 width=256)
Filter: ((dwbh)::text = '1002'::text)
-> Hash Join (cost=16.15..36.12 rows=7 width=180)
Hash Cond: ((t_jfxx_1.grbh)::text = (t_grxx_1.grbh)::text)
-> Seq Scan on t_jfxx t_jfxx_1 (cost=0.00..17.20 rows=720 width=84)
-> Hash (cost=16.12..16.12 rows=2 width=134)
-> Seq Scan on t_grxx t_grxx_1 (cost=0.00..16.12 rows=2 width=134)
Filter: ((dwbh)::text = '1002'::text)
(22 rows)
二、对照关系
对照关系详见下图:
对照关系
结合关系代数的理论和相关术语,可以更好的理解执行计划。
三、小结
上一小节已通过分析日志的方式介绍了PlannedStmt的结构,这一小节结合执行计划进行对照解析,可以加深对执行计划的理解和认识。
编辑推荐:
- PostgreSQL 源码解读(23)- 查询语句#8(PlannedStmt与QUERY P...03-14
- postgres中正则表达式及转义03-14
- PostgreSQL扫盲教程03-14
- PostgreSQL 源码解读(25)- 查询语句#10(查询优化概览)03-14
- 良好的协作03-14
- 如何实现单机版DataBase:概览03-14
- 如何快速的了解某种数据库03-14
- PostgreSQL Page页结构解析(1)-基础03-14
下一篇:
相关推荐
-
雷神推出 MIX PRO II 迷你主机:基于 Ultra 200H,玻璃上盖 + ARGB 灯效
2 月 9 日消息,雷神 (THUNDEROBOT) 现已宣布推出基于英
-
制造商 Musnap 推出彩色墨水屏电纸书 Ocean C:支持手写笔、第三方安卓应用
2 月 10 日消息,制造商 Musnap 现已在海外推出一款 Oce
热文推荐
- PostgreSQL 源码解读(23)- 查询语句#8(PlannedStmt与QUERY P...
- PostgreSQL扫盲教程
PostgreSQL扫盲教程
26-03-14 - 如何实现单机版DataBase:概览
如何实现单机版DataBase:概览
26-03-14 - PostgreSQL Page页结构解析(1)-基础
PostgreSQL Page页结构解析(1)-基础
26-03-14 - PostgreSQL 数据页Page解析(1)- 基础
PostgreSQL 数据页Page解析(1)- 基础
26-03-14 - PostgreSQL的几个概念
PostgreSQL的几个概念
26-03-14 - 爱开源的谷歌又来了,这次发布的是数据库备份完整性检查工具
爱开源的谷歌又来了,这次发布的是数据库备份完整性检查工具
26-03-14 - Greenplum集群部署小记
Greenplum集群部署小记
26-03-14 - 第一家GraphQL即服务公司出现,瞄准的第一个数据库便是Postgres!
- 使用Navicat连接远程服务器中在docker中运行的MySQL数据库全过程
