久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

PostgreSQL在執(zhí)行邏輯優(yōu)化中相關的數(shù)據(jù)結構是什么

137次閱讀
沒有評論

共計 4392 個字符,預計需要花費 11 分鐘才能閱讀完成。

這篇文章主要介紹“PostgreSQL 在執(zhí)行邏輯優(yōu)化中相關的數(shù)據(jù)結構是什么”,在日常操作中,相信很多人在 PostgreSQL 在執(zhí)行邏輯優(yōu)化中相關的數(shù)據(jù)結構是什么問題上存在疑惑,丸趣 TV 小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”PostgreSQL 在執(zhí)行邏輯優(yōu)化中相關的數(shù)據(jù)結構是什么”的疑惑有所幫助!接下來,請跟著丸趣 TV 小編一起來學習吧!

一、數(shù)據(jù)結構

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 個子節(jié)點) 更為靈活  --  不需要處理別名等.
 *  輸出列集合是子集輸出的匯總.
 *----------
 */
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, 則解析器會產(chǎn)生相應的 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 存在的目的主要是可以創(chuàng)建引用 join 輸出的 Vars.
 *  計劃器有時候會在內(nèi)部生成 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 在執(zhí)行邏輯優(yōu)化中相關的數(shù)據(jù)結構是什么”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關知識,請繼續(xù)關注丸趣 TV 網(wǎng)站,丸趣 TV 小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

正文完
 
丸趣
版權聲明:本站原創(chuàng)文章,由 丸趣 2023-07-24發(fā)表,共計4392字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網(wǎng)絡搜集發(fā)布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 集安市| 江源县| 尖扎县| 固原市| 临西县| 鹰潭市| 积石山| 临澧县| 巴彦淖尔市| 长兴县| 贵溪市| 祁东县| 上虞市| 阿坝县| 五家渠市| 罗山县| 卢氏县| 香格里拉县| 库伦旗| 株洲市| 绥宁县| 阳春市| 金沙县| 湖南省| 微山县| 南澳县| 武鸣县| 启东市| 杨浦区| 台安县| 乡宁县| 洛浦县| 大英县| 正镶白旗| 桦甸市| 吴堡县| 莆田市| 台北市| 郎溪县| 久治县| 益阳市|