摘要:
继续:/* * estimate_rel_size - estimate # pages and # tuples in a table or index * * We also estimate the fraction of the pages that are marked all-visible in * the visibility map, for use in estimation of index-only scans. * * If attr_widths isn't NULL, it points to the zero-index entry of the * r 阅读全文
摘要:
接着分析:build_simple_rel 函数/* * build_simple_rel * Construct a new RelOptInfo for a base relation or 'other' relation. */RelOptInfo *build_simple_rel(PlannerInfo *root, int relid, RelOptKind reloptkind){ ... /* Check type of rtable entry */ switch (rte->rtekind) { case RTE_RELAT... 阅读全文
摘要:
如此:接前面,看 add_base_rels_to_query函数:/* * add_base_rels_to_query * * Scan the query's jointree and create baserel RelOptInfos for all * the base relations (ie, table, subquery, and function RTEs) * appearing in the jointree. * * The initial invocation must pass root->parse->jointree as t... 阅读全文
摘要:
Path莫非指的就是 物理访问路径?/* * 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 itself... 阅读全文
摘要:
继续:/*-------------------- * grouping_planner * Perform planning steps related to grouping, aggregation, etc. * This primarily means adding top-level processing to the basic * query plan produced by query_planner. * * tuple_fraction is the fraction of tuples we expect will be retrieved... 阅读全文
摘要:
接前面,对 subquery_planner,进行进一步的分析:/*-------------------- * 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 & rewr... 阅读全文
摘要:
接前面,继续进行分析:前面已经说过,在planner函数运行时,发生了实际物理磁盘访问。/***************************************************************************** * * Query optimizer entry point * * To support loadable plugins that monitor or modify planner behavior, * we provide a hook variable that lets a plugin get control before... 阅读全文
摘要:
回到 exec_simple_query函数上来。/* * exec_simple_query * * Execute a "simple Query" protocol message. */static voidexec_simple_query(const char *query_string){ ... start_xact_command(); ... parsetree_list = pg_parse_query(query_string); ... /* * Run through the raw parsetree(s) an... 阅读全文
摘要:
今天进行了一个小实验,发现一个奇怪的现象:我当前有这样的数据:postgres=# select * from tab01; id | val ----+----- 1 | 100 2 | 200 3 | 300(3 rows)postgres=# 并且通过查询数据字典,知道 tab01 对应的文件名是:/usr/local/pgsql/data/base/12788/16385然后重新启动数据库。开启两个psql 客户端第一个客户端执行:postgres=# select * from tab01 where id=1; id | val ----+----- 1 | 100(1 r... 阅读全文
摘要:
调用关系:PortalRun ->PortalRunSelect -> ExecutorRunExecutorRun,实际上会去运行 standard_ExecutorRun ->ExecutePlan:/* ---------------------------------------------------------------- * ExecutorRun * * This is the main routine of the executor module. It accepts * the query descriptor from the... 阅读全文