In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "what is the relevant data structure of PostgreSQL in the implementation of logic optimization". In daily operation, I believe many people have doubts about what the data structure related to the implementation of logic optimization in PostgreSQL is. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "what is the relevant data structure of PostgreSQL in the implementation of logic optimization". Next, please follow the editor to study!
I. data structure
FromExpr
It means FROM... WHERE structure
/ *-* FromExpr-represents a FROM WHERE... Construct * stands for FROM. WHERE structure * * 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. * this structure is more flexible than JoinExpr (with 0.. n child nodes)-there is no need to deal with aliases, etc. * the set of output columns is a summary of the output of a subset. *-* / typedef struct FromExpr {NodeTag type; / / the expression Node * quals; / * qualifiers on join, if any * /} FromExpr in the linked subtree list List * fromlist; / * List of join subtrees * / join
JoinExpr
Used for SQL JOIN expressions.
/ *-* JoinExpr-for SQL JOIN expressions * is used for SQL JOIN expressions. * * 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 and quals are interdependent. * users can only use NATURAL, USING (), or ON () (syntax restrictions). * if it is NATURAL, the parser produces the corresponding USING () linked list and populates the quals with the correct equivalent comparison expression. * in the case of USING (), fill quals with the correct equivalent comparison expression. * if it is ON (), only the quals field is set. * Note that NATURAL/USING and ON () are not the same because they also affect the output column list. * 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 denotes the AS alias clause associated with the join expression, or NULL if none. * Note: the existence of aliases has a great impact on semantics, so join with aliases limits the visibility of tables / columns in it. * * 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. * when parsing, RTE parses when participating in Join, and the number is populated in the rtindex. * the main purpose of this RTE is to create a Vars that references the join output. * the planner sometimes generates JoinExprs; internally if there is no join alias variable reference such a connection, then rtindex = 0 *-* / typedef struct JoinExpr {NodeTag type; / / join type JoinType jointype; / * type of join * / / natural connection? Bool isNatural; / * Natural join? Will need to shape table * / / left tree Node * larg; / * left subtree * / / right tree Node * rarg; / * right subtree * / / USING statement (String linked list) List * usingClause; / * USING clause, if any (list of String) * / / join qualifier Node * quals; / * qualifiers on join, if any * / / alias statement Alias * alias / * user-written alias clause, if any * / / the RT number assigned to join, or 0 int rtindex; / * RT index assigned for join, or 0 * /} JoinExpr; II. Source code interpretation
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, isNatural = larg, larg = 0x2b66de0, 0x2b66de0 = 0x2b66de0, 0x2b66de0, = 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}. At this point, the study on "what is the relevant data structure of PostgreSQL in implementing logic optimization" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.