博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PostgreSQL 源码解读(23)- 查询语句#8(PlannedStmt与QUERY P...
阅读量:2497 次
发布时间:2019-05-11

本文共 2655 字,大约阅读时间需要 8 分钟。

一、测试脚本
testdb=# explain testdb-# select * from (testdb(# select t_dwxx.dwmc,t_grxx.grbh,t_grxx.xm,t_jfxx.ny,t_jfxx.jetestdb(# from t_dwxx inner join t_grxx on t_dwxx.dwbh = t_grxx.dwbhtestdb(# inner join t_jfxx on t_grxx.grbh = t_jfxx.grbhtestdb(# where t_dwxx.dwbh IN ('1001')testdb(# union alltestdb(# select t_dwxx.dwmc,t_grxx.grbh,t_grxx.xm,t_jfxx.ny,t_jfxx.jetestdb(# from t_dwxx inner join t_grxx on t_dwxx.dwbh = t_grxx.dwbhtestdb(# inner join t_jfxx on t_grxx.grbh = t_jfxx.grbhtestdb(# where t_dwxx.dwbh IN ('1002') testdb(# ) as rettestdb-# order by ret.grbhtestdb-# 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)

二、对照关系

对照关系详见下图:

bb

对照关系

结合关系代数的理论和相关术语,可以更好的理解执行计划。

三、小结

上一小节已通过分析日志的方式介绍了PlannedStmt的结构,这一小节结合执行计划进行对照解析,可以加深对执行计划的理解和认识。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/6906/viewspace-2374893/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/6906/viewspace-2374893/

你可能感兴趣的文章
优先队列
查看>>
一些程序和工具
查看>>
java8 运算语法集
查看>>
IDEA关于重命名
查看>>
Es6 中let var和 const 了解
查看>>
巧用队列之”Voting“
查看>>
Oracle数据类型number(m,n)
查看>>
C#多线程学习(一) 多线程的相关概念
查看>>
JS构造函数、原型对象、隐含参数this
查看>>
注册用户
查看>>
TZC Intercommunication System
查看>>
HDU 4571 SPFA+DP
查看>>
centos 创建以日期为名的文件夹
查看>>
Java Timer触发定时器
查看>>
Page Object设计模式
查看>>
程序的基础知识
查看>>
FreeModbus在STM32上移植(转)
查看>>
使用 pjax 载入的新页面,新页面上 类方法 无法被触发?
查看>>
sql server从一个数据库复制一个表到另一个数据库的方法
查看>>
微软正式公布Win8版本 ARM版命名为Windows RT
查看>>