PostgreSQL在执行逻辑优化中相关的数据结构是什么
发表于:2025-02-02 作者:千家信息网编辑
千家信息网最后更新 2025年02月02日,这篇文章主要介绍"PostgreSQL在执行逻辑优化中相关的数据结构是什么",在日常操作中,相信很多人在PostgreSQL在执行逻辑优化中相关的数据结构是什么问题上存在疑惑,小编查阅了各式资料,整理
千家信息网最后更新 2025年02月02日PostgreSQL在执行逻辑优化中相关的数据结构是什么
这篇文章主要介绍"PostgreSQL在执行逻辑优化中相关的数据结构是什么",在日常操作中,相信很多人在PostgreSQL在执行逻辑优化中相关的数据结构是什么问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答"PostgreSQL在执行逻辑优化中相关的数据结构是什么"的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
一、数据结构
FromExpr
表示FROM … WHERE结构
/*---------- * FromExpr - represents a FROM ... WHERE ... construct * 表示FROM ... WHERE结构 * * This is both more flexible than a JoinExpr (it can have any number of * children, including zero) and less so --- we don't need to deal with * aliases and so on. The output column set is implicitly just the union * of the outputs of the children. * 该结构比JoinExpr(有0..n个子节点)更为灵活 -- 不需要处理别名等. * 输出列集合是子集输出的汇总. *---------- */typedef struct FromExpr{ NodeTag type; //连接子树链表 List *fromlist; /* List of join subtrees */ //join中的表达式 Node *quals; /* qualifiers on join, if any */} FromExpr;
JoinExpr
用于SQL JOIN表达式.
/*---------- * JoinExpr - for SQL JOIN expressions * 用于SQL JOIN表达式. * * isNatural, usingClause, and quals are interdependent. The user can write * only one of NATURAL, USING(), or ON() (this is enforced by the grammar). * If he writes NATURAL then parse analysis generates the equivalent USING() * list, and from that fills in "quals" with the right equality comparisons. * If he writes USING() then "quals" is filled with equality comparisons. * If he writes ON() then only "quals" is set. Note that NATURAL/USING * are not equivalent to ON() since they also affect the output column list. * isNatural, usingClause, and quals是相互依赖的. * 用户只可以使用NATURAL, USING(), or ON()(语法限制). * 如果是NATURAL,则解析器会产生相应的USING()链表,并使用正确的等值比较表达式填充quals. * 如果是USING(),则使用正确的等值比较表达式填充quals. * 如果是ON(),则只设置quals字段. * 注意NATURAL/USING与ON()并不相同,因为它们同时影响了输出列链表. * * alias is an Alias node representing the AS alias-clause attached to the * join expression, or NULL if no clause. NB: presence or absence of the * alias has a critical impact on semantics, because a join with an alias * restricts visibility of the tables/columns inside it. * alias表示与join表达式相关的AS别名子句,如无则为NULL. * 注意:别名的存在与否对语义有很大影响,因此有别名的join限制了其中表/列的可见性. * * During parse analysis, an RTE is created for the Join, and its index * is filled into rtindex. This RTE is present mainly so that Vars can * be created that refer to the outputs of the join. The planner sometimes * generates JoinExprs internally; these can have rtindex = 0 if there are * no join alias variables referencing such joins. * 在解析时,RTE在参与Join时解析,编号填充到rtindex中. * 该RTE存在的目的主要是可以创建引用join输出的Vars. * 计划器有时候会在内部生成JoinExprs;如没有join别名变量参考这样的连接,那么rtindex = 0 *---------- */typedef struct JoinExpr{ NodeTag type; //join类型 JoinType jointype; /* type of join */ //自然连接? bool isNatural; /* Natural join? Will need to shape table */ //左树 Node *larg; /* left subtree */ //右树 Node *rarg; /* right subtree */ //USING语句(String链表) List *usingClause; /* USING clause, if any (list of String) */ //join限定符 Node *quals; /* qualifiers on join, if any */ //别名语句 Alias *alias; /* user-written alias clause, if any */ //分配给join的RT编号,或者为0 int rtindex; /* RT index assigned for join, or 0 */} JoinExpr;
二、源码解读
N/A
三、跟踪分析
...(gdb) p *(FromExpr *)($rte_sq_rte->subquery->jointree)$44 = {type = T_FromExpr, fromlist = 0x16fda18, quals = 0x16fe0f0}(gdb) set $rtesq2_jointree=(FromExpr *)($rte_sq_rte->subquery->jointree)(gdb) p *$rtesq2_jointree->fromlist$48 = {type = T_List, length = 1, head = 0x16fd9f8, tail = 0x16fd9f8}(gdb) p *(Node *)$rtesq2_jointree->fromlist->head->data.ptr_value$49 = {type = T_JoinExpr}(gdb) set $tmpvar=(JoinExpr *)$rtesq2_jointree->fromlist->head->data.ptr_value(gdb) p *$tmpvar$3 = {type = T_JoinExpr, jointype = JOIN_INNER, isNatural = false, larg = 0x2b68730, rarg = 0x2c215e8, usingClause = 0x0, quals = 0x2c28130, alias = 0x0, rtindex = 5}(gdb) p *$tmpvar->larg$4 = {type = T_JoinExpr}(gdb) p *(JoinExpr *)$tmpvar->larg$5 = {type = T_JoinExpr, jointype = JOIN_INNER, isNatural = false, larg = 0x2c1e848, rarg = 0x2c1ebd8, usingClause = 0x0, quals = 0x2c20c48, alias = 0x0, rtindex = 3}(gdb) p *(JoinExpr *)$tmpvar->rarg$6 = {type = T_RangeTblRef, jointype = JOIN_SEMI, isNatural = 8, larg = 0x2b66de0, rarg = 0x636d7764, usingClause = 0x10, quals = 0x2b66de0, alias = 0xda, rtindex = 46274048}(gdb) p *(JoinExpr *)$tmpvar->quals$7 = {type = T_OpExpr, jointype = 98, isNatural = 67, larg = 0x0, rarg = 0x64, usingClause = 0x2c27fb8, quals = 0xa9, alias = 0x0, rtindex = 0}...
到此,关于"PostgreSQL在执行逻辑优化中相关的数据结构是什么"的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注网站,小编会继续努力为大家带来更多实用的文章!
结构
别名
表达式
数据
数据结构
逻辑
学习
输出
更多
语句
帮助
影响
限制
实用
很大
相同
接下来
个子
变量
同时
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
温馨世界服务器
服务器管理ip登陆不了
服务器架构图软件有哪些
幸福工厂添加服务器
c 修改数据库数据
武易传奇物品数据库
生产效率软件开发公司
阿里云服务器25端口
服务器的基本配置
阿里云服务器怎么续费
阿里网络安全高级工程师
网络安全四个著名理论
共同筑牢网络安全
云服务器安装cadence
自己家里可以弄台服务器吗
软件开发项目进度情况说明
服务器数据交换怎么没反映
网络安全普及节目
中国基因数据库有几个
3.1日网络安全法
国服第一手游服务器
陆陆互联网络科技
海淀软件开发公司
服务器串口
ps5如何看登录的服务器
上海立体化软件开发公司
服务器消耗品
政府 职能 网络安全 公司
北京欧维时代网络技术
具有计算机网络技术的专业