您好,登錄后才能下訂單哦!
這篇文章主要介紹“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在執行邏輯優化中相關的數據結構是什么”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。