当前位置:网站首页>Opengauss kernel analysis: query rewriting
Opengauss kernel analysis: query rewriting
2022-07-24 23:26:00 【InfoQ】
Query rewriting

External connection elimination Outer2Inner
create table t1(c1 int, c2 int);
create table t2(c1 int, c2 int);
insert into t1 values(1, 10);
insert into t1 values(2, 20);
insert into t1 values(3, 30);
insert into t2 values(1, 100);
insert into t2 values(3, 300);
insert into t2 values(5, 500);
SELECT * FROM t1 inner JOIN t2 ON t1.c1 = t2.c1;SELECT * FROM t1 Left OUTER JOIN t2 ON t1.c1 = t2.c1;SELECT * FROM t1 right OUTER JOIN t2 ON t1.c1 = t2.c1;SELECT * FROM t1 full JOIN t2 ON t1.c1 = t2.c1;



void reduce_outer_joins(PlannerInfo* root)
{
reduce_outer_joins_state* state = NULL;
state = reduce_outer_joins_pass1((Node*)root->parse->jointree);
/* planner.c shouldn't have called me if no outer joins */
if (state == NULL || !state->contains_outer)
ereport(ERROR,
(errmodule(MOD_OPT),
errcode(ERRCODE_OPTIMIZER_INCONSISTENT_STATE),
(errmsg("so where are the outer joins?"))));
reduce_outer_joins_pass2((Node*)root->parse->jointree, state, root, NULL, NIL, NIL);
}
(gdb) p *((JoinExpr*)(parse->jointree->fromlist->head.data->ptr_value))
$1 = {type = T_JoinExpr, jointype = JOIN_INNER, isNatural = false, larg = 0x7fdfb345cd08, rarg = 0x7fdfb345e2e8, usingClause = 0x0, quals = 0x7fdfb2f0b8a8, alias = 0x0, rtindex = 3}
(gdb) p *(RangeTblEntry*)(parse->rtable->tail.data->ptr_value)
$2 = {type = T_RangeTblEntry, rtekind = RTE_JOIN, relname = 0x0, partAttrNum = 0x0, relid = 0, partitionOid = 0, isContainPartition = false, subpartitionOid = 0, isContainSubPartition = false,
refSynOid = 0, partid_list = 0x0, relkind = 0 '\000', isResultRel = false, tablesample = 0x0, timecapsule = 0x0, ispartrel = false, ignoreResetRelid = false, subquery = 0x0, security_barrier = false,
jointype = JOIN_INNER, …}边栏推荐
- 老杜Servlet-JSP
- The rule created by outlook mail is invalid. Possible reasons
- WPF opens external programs and activates them when needed
- 常用在线测试工具集合
- Piziheng embedded: the method of making source code into lib Library under MCU Xpress IDE and its difference with IAR and MDK
- Shell调试Debug的三种方式
- 国信证券手机开户安全吗
- 买收益百分之6的理财产品,需要开户吗?
- Talk about how redis handles requests
- Burp's thinking from tracing to counteracting
猜你喜欢

CA证书制作实战

Go basic notes_ 4_ map

Heap sort summary

Notes of Teacher Li Hongyi's 2020 in-depth learning series 2

Xiezhendong: Exploration and practice of digital transformation and upgrading of public transport industry

QT6 with vs Code: compiling source code and basic configuration

痞子衡嵌入式:MCUXpresso IDE下将源码制作成Lib库方法及其与IAR,MDK差异

Notes of Teacher Li Hongyi's 2020 in-depth learning series lecture 1

Network Security Learning (IV) user and group management, NTFS

Notes of Teacher Li Hongyi's 2020 in-depth learning series 5
随机推荐
Some analysis of slow MySQL query
Nvida tensorrt deployment (I)
Baidu online disk +chrome plug-in
认识复杂度和简单排序运算
必会面试题:1.浅拷贝和深拷贝_深拷贝
Qt | 事件系统 QEvent
Which securities account is the best and safest for beginners
高阶产品如何提出有效解决方案?(1方法论+2案例+1清单)
Power consumption of chip
TrinityCore魔兽世界服务器-注册网站
burp从溯源到反制思路
Js----- Chapter 4 array
The size of STM32 stack
Read and understand the advantages of the LAAS scheme of elephant swap
给生活加点惊喜,做创意生活的原型设计师丨编程挑战赛 x 选手分享
如何创建和管理自定义的配置信息
郑慧娟:基于统一大市场的数据资产应用场景与评估方法研究
买收益百分之6的理财产品,需要开户吗?
Three ways of shell debugging and debugging
解决JSP无法使用session.getAttribute()