这篇文章主要介绍“postgresql在执行逻辑优化中相关的数据结构有哪些”,在日常操作中,相信很多人在Postgresql在执行逻辑优化中相关的数据结构有哪些问题上存在疑惑,小编查阅了各式资料,整理出简单
这篇文章主要介绍“postgresql在执行逻辑优化中相关的数据结构有哪些”,在日常操作中,相信很多人在Postgresql在执行逻辑优化中相关的数据结构有哪些问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”PostgreSQL在执行逻辑优化中相关的数据结构有哪些”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
PostgreSQL在执行逻辑优化中相关的数据结构包括RangeSubselect/Alias/RangeVar/ResTarget/ColumnRef.
RangeSubselect
出现在FROM语句中的子查询
typedef struct RangeSubselect
{
nodeTag type;
//是否有LATERAL?
bool lateral;
//未转换的子查询语句
Node *subquery;
//表别名和可选的列别名
Alias *alias;
} RangeSubselect;
Alias
为RangeVar指定别名.别名可能同时重命名了表列.
typedef struct Alias
{
NodeTag type;
//别名
char *aliasname;
//列别名链表
List *colnames;
} Alias;
RangeVar
range variable,用于FROM语句中.
typedef struct RangeVar
{
NodeTag type;
char *catalogname;
char *schemaname;
char *relname;
bool inh;
char relpersistence;
Alias *alias;
int location;
} RangeVar;
ResTarget
结果目标列(用于先前已转换的解析树的目标链表中)
typedef struct ResTarget
{
NodeTag type;
//列名或NULL
char *name;
//子脚本,字段名称,'*'或NIL
List *indirection;
//需要计算或赋值的值表达式
Node *val;
//token的位置,-1表示未知
int location;
} ResTarget;
ColumnRef
指定对列或整个元组的引用
typedef struct ColumnRef
{
NodeTag type;
//字段名称(字符串值)链表或A_Star
List *fields;
//token位置
int location;
} ColumnRef;
N/A
RangeSubselect/Alias
(gdb) p *(Node *)($stmt->fromClause->head.data->ptr_value)
$15 = {type = T_RangeSubselect} #实际类型是范围子查询RangeSubselect
(gdb) set $fromclause=(RangeSubselect *)($stmt->fromClause->head.data->ptr_value)
(gdb) p *$fromclause
$16 = {type = T_RangeSubselect, lateral = false, subquery = 0x1666c18, alias = 0x1666d40}
(gdb) p *($fromclause->subquery) #subquery,子查询是SelectStmt类型的节点
$17 = {type = T_SelectStmt}
(gdb) p *($fromclause->alias) #alias,别名,实际值是字符串ret
$18 = {type = T_Alias, aliasname = 0x1666d28 "ret", colnames = 0x0}
RangeVar
...
$43 = {type = T_RangeVar}
(gdb) p *(RangeVar *)((JoinExpr *)($joinexpr->larg))->larg
$44 = {type = T_RangeVar, catalogname = 0x0, schemaname = 0x0, relname = 0x1643380 "t_dwxx", inh = true,
relpersistence = 112 'p', alias = 0x0, location = 82}
...
ResTarget
...
(gdb) p *(Node *)($subquerylarg->targetList->head.data->ptr_value)
$26 = {type = T_ResTarget}
(gdb) set $subvar=(ResTarget *)($subquerylarg->targetList->head.data->ptr_value)
(gdb) p *$subvar
{type = T_ResTarget, name = 0x0, indirection = 0x0, val = 0x1642c70, location = 23}
...
ColumnRef
...
(gdb) p *$restarget->val
$25 = {type = T_ColumnRef}
(gdb) p *(ColumnRef *)$restarget->val
$26 = {type = T_ColumnRef, fields = 0x1a47a08, location = 7}
(gdb) p *((ColumnRef *)$restarget->val)->fields
$27 = {type = T_List, length = 2, head = 0x1a47a88, tail = 0x1a479e8}
(gdb) p *(Node *)(((ColumnRef *)$restarget->val)->fields)->head.data->ptr_value
$32 = {type = T_String}
#fields链表的第1个元素是数据表,第2个元素是数据列
(gdb) p *(Value *)(((ColumnRef *)$restarget->val)->fields)->head.data->ptr_value
$37 = {type = T_String, val = {ival = 27556248, str = 0x1a47998 "t_dwxx"}}
(gdb) p *(Value *)(((ColumnRef *)$restarget->val)->fields)->tail.data->ptr_value
$38 = {type = T_String, val = {ival = 27556272, str = 0x1a479b0 "dwmc"}}
...
到此,关于“PostgreSQL在执行逻辑优化中相关的数据结构有哪些”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注编程网网站,小编会继续努力为大家带来更多实用的文章!
--结束END--
本文标题: PostgreSQL在执行逻辑优化中相关的数据结构有哪些
本文链接: https://lsjlt.com/news/63864.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0