当前位置:网站首页>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, …}边栏推荐
- 高阶产品如何提出有效解决方案?(1方法论+2案例+1清单)
- QT | event system qevent
- The specified data is grouped and the number of repetitions is obtained in Oracle
- Piziheng embedded: the method of making source code into lib Library under MCU Xpress IDE and its difference with IAR and MDK
- 新手哪个证券开户最好 开户最安全
- IP first experiment hdcl encapsulates PPP, chap, mGRE
- Notes of Teacher Li Hongyi's 2020 in-depth learning series 9
- Go basic notes_ 4_ map
- 谢振东:公共交通行业数字化转型升级的探索与实践
- ODBC executes stored procedure to get return value
猜你喜欢

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

基于FPGA的VGA显示

With screen and nohup running, there is no need to worry about deep learning code anymore | exiting the terminal will not affect the operation of server program code

Digital stopwatch based on Verilog HDL

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

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

Some analysis of slow MySQL query

Understanding complexity and simple sorting operation

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

给生活加点惊喜,做创意生活的原型设计师丨编程挑战赛 x 选手分享
随机推荐
Nvida tensorrt deployment (I)
凸优化基础知识
Pointrender parsing
【零基础】php代码审计之sql注入
Power consumption of chip
买收益百分之6的理财产品,需要开户吗?
WPF opens external programs and activates them when needed
Qt | 事件系统 QEvent
In pgplsql: = and=
With screen and nohup running, there is no need to worry about deep learning code anymore | exiting the terminal will not affect the operation of server program code
Add a little surprise to life and be a prototype designer of creative life -- sharing with X contestants in the programming challenge
必会面试题:1.浅拷贝和深拷贝_深拷贝
Go基础笔记_4_map
Which securities account is the best and safest for beginners
代码覆盖率
Can the income of CICC securities' new customer financial products reach 6%? How to open an account?
QT6 with vs Code: compiling source code and basic configuration
MySQL查询慢的一些分析
Three ways of shell debugging and debugging
CA证书制作实战