摘要:
再次梳理 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){ RelOptInfo *rel; RangeTblEntry *rte; /* Rel should not exist already */ Assert... 阅读全文
摘要:
接前面,回到get_relation_info(plancat.c)函数 上:relation 是由 heap_open 函数调用后获得的。voidget_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent, RelOptInfo *rel){ Index varno = rel->relid; Relation relation; bool hasindex; List *indexinfos = NI... 阅读全文
摘要:
再次回到 estimate_rel_size 我发现,在入口参数 rel中,rel->rd_rel->reltuples 的值已经完全准备好了:/* * 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. * * 阅读全文
摘要:
接前面。回到程序调用关系上来:estimate_rel_size -> RelationGetNumberOfBlocks->RelationGetNumberOfBlocksINFork->Smgrnblocks->mdnblocks...折腾了一圈,就是为了评估一个表的大小。那么,我们所获得的block,它到底是个什么单位?BlockNumbermdnblocks(SMgrRelation reln, ForkNumber forknum){ MdfdVec *v = mdopen(reln, forknum, EXTENSION_FAIL); BlockNumbe 阅读全文
摘要:
接前面:回到mdopen上来,看看是谁调用了 mdopen,又获得了什么。/* * mdnblocks() -- Get the number of blocks stored in a relation. * * Important side effect: all active segments of the relation are opened * and added to the mdfd_chain list. If this routine has not been * called, then only segments up ... 阅读全文