Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the processing logic of query_planner function in PostgreSQL

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

< root->

Simple_rel_array_size; rti++) / / calculate the total pages {RelOptInfo * brel = root- > simple_rel_ array [RTI]; if (brel = = NULL) continue; Assert (brel- > relid = = rti); / * sanity check on array * / if (IS_SIMPLE_REL (brel)) total_pages + = (double) brel- > pages;} root- > total_table_pages = total_pages / / assign / * * Ready to do the primary planning. * / final_rel = make_one_rel (root, joinlist); / / execute the main planning process / * Check that we got at least one usable path * / if (! final_rel | |! final_rel- > cheapest_total_path | | final_rel- > cheapest_total_path- > param_info! = NULL) elog (ERROR, "failed to construct the join relation"); / / check the result returned by return final_rel;//}

Setup_simple_rel_arrays

Initialize setup_simple_rel_arrays (Note: [0] useless) and setup_simple_rel_arrays

/ * * setup_simple_rel_arrays * Prepare the arrays we use for quickly accessing base relations. * / void setup_simple_rel_arrays (PlannerInfo * root) {Index rti; ListCell * lc; / * Arrays are accessed using RT indexes (1.. N) * / root- > simple_rel_array_size = list_length (root- > parse- > rtable) + 1; / * simple_rel_array is initialized to all NULLs * / root- > simple_rel_array = (RelOptInfo * *) palloc0 (root- > simple_rel_array_size * sizeof (RelOptInfo *)) / * simple_rte_array is an array equivalent of the rtable list * / root- > simple_rte_array = (RangeTblEntry * *) palloc0 (root- > simple_rel_array_size * sizeof (RangeTblEntry *)); rti = 1; foreach (lc, root- > parse- > rtable) {RangeTblEntry * rte = (RangeTblEntry *) lfirst (lc); root- > simple_rte_ array [RTI + +] = rte;}}

Setup_append_rel_array

The source code is relatively simple. Read the information in append_rel_list to initialize append_rel_array.

/ * * setup_append_rel_array * Populate the append_rel_array to allow direct lookups of * AppendRelInfos by child relid. * * The array remains unallocated if there are no AppendRelInfos. * / void setup_append_rel_array (PlannerInfo * root) {ListCell * lc; int size = list_length (root- > parse- > rtable) + 1; if (root- > append_rel_list = = NIL) {root- > append_rel_array = NULL; return;} root- > append_rel_array = (AppendRelInfo *) palloc0 (size * sizeof (AppendRelInfo *)) Foreach (lc, root- > append_rel_list) {AppendRelInfo * appinfo = lfirst_node (AppendRelInfo, lc); int child_relid = appinfo- > child_relid; / * Sanity check * / Assert (child_relid

< size); if (root->

Append_rel_ array [child _ relid]) elog (ERROR, "child relation already exists"); root- > append_rel_ array [child _ relid] = appinfo }} Thank you for your reading, the above is the content of "what is the query_planner function processing logic in PostgreSQL". After the study of this article, I believe you have a deeper understanding of how the query_planner function processing logic in PostgreSQL is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report