摘要:
开始 /* * Ready to do the primary planning. */ final_rel = make_one_rel(root, joinlist);展开:/* * make_one_rel * Finds all possible access paths for executing a query, returning a * single rel that represents the join of all base rels in the query. */RelOptInfo *make_one_rel(Plan... 阅读全文
摘要:
继续分析 query_planner:/* * query_planner * Generate a path (that is, a simplified plan) for a basic query, * which may involve joins but not any fancier features. * * Since query_planner does not handle the toplevel processing (grouping, * sorting, etc) it cannot select the best path by itsel... 阅读全文
摘要:
接前面: Query *parse = root->parse; List *tlist = parse->targetList; int64 offset_est = 0; int64 count_est = 0; double limit_tuples = -1.0; Plan *result_plan; List *current_pathkeys; double dNumGroups = 0; bool use_ha... 阅读全文
摘要:
接前面,继续对 subquery_planner来分析:下面这一段都是对 表达式进行处理的,对我的简单查询,可以忽略。 /* * Do expression preprocessing on targetlist and quals, as well as other * random expressions in the querytree. Note that we do not need to * handle sort/group expressions explicitly, because they are actually * part o... 阅读全文
摘要:
接着,分析:/*-------------------- * subquery_planner * Invokes the planner on a subquery. We recurse to here for each * sub-SELECT found in the query tree. * * glob is the global state for the current planner run. * parse is the querytree produced by the parser & rewriter. * parent_root is the... 阅读全文
摘要:
再次上溯:/*-------------------- * subquery_planner * Invokes the planner on a subquery. We recurse to here for each * sub-SELECT found in the query tree. * * glob is the global state for the current planner run. * parse is the querytree produced by the parser & rewriter. * parent_root is the ... 阅读全文
摘要:
接前面,再上溯:set_base_rel_pathlists -->set_rel_pathlist/* * set_base_rel_pathlists * Finds all paths available for scanning each base-relation entry. * Sequential scan and any available indices are considered. * Each useful path is attached to its relation's 'pathlist' field. */static void 阅读全文
摘要:
现在,将要进入最为重要的部分:分析如何制作执行计划的。先把它简化,看看NodeTag 在 PortalStart 之前,是如何得到的。先找到第一个相关程序:每一种执行计划(结点单位),都有一个对应的path。/***************************************************************************** * PATH NODE CREATION ROUTINES *****************************************************************************//*... 阅读全文
摘要:
回溯:PortalRun --> PortalRunSelectboolPortalRun(Portal portal, long count, bool isTopLevel, DestReceiver *dest, DestReceiver *altdest, char *completionTag){ ... portal->status = PORTAL_ACTIVE; ... PG_TRY(); { ActivePortal = portal; CurrentResourceOwner = ... 阅读全文
摘要:
再次上溯:可以知道,在 ExecutePlan入口参数里面,start_block 就已经是0了。/* ---------------------------------------------------------------- * ExecutePlan * * Processes the query plan until we have processed 'numberTuples' tuples, * moving in the specified direction. * * Runs to completion if nu... 阅读全文