zoukankan      html  css  js  c++  java
  • PostgreSQL在何处处理 sql查询之二十四

    接前面,回到 get_relation_info(plancat.c)函数 上:

    relation 是由 heap_open 函数调用后获得的。

    void
    get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
                      RelOptInfo *rel)
    {
        Index        varno = rel->relid;
        Relation    relation;
        bool        hasindex;
        List       *indexinfos = NIL;
    
        /*
         * We need not lock the relation since it was already locked, either by
         * the rewriter or when expand_inherited_rtentry() added it to the query's
         * rangetable.
         */
        relation = heap_open(relationObjectId, NoLock);
    
        ...
        /*
         * Estimate relation size --- unless it's an inheritance parent, in which
         * case the size will be computed later in set_append_rel_pathlist, and we
         * must leave it zero for now to avoid bollixing the total_table_pages
         * calculation.
         */
        if (!inhparent)
            estimate_rel_size(relation, rel->attr_widths - rel->min_attr,
                              &rel->pages, &rel->tuples, &rel->allvisfrac);
    
        ...
    }

    经过验证,heap_open后,就把relation的一些信息准备好了。

    其中包括  relation->rd_rel->reltuples。

    仍然回到  此get_relation_info函数中,当我访问表 tst01时(其对应文件为 16384),

    我可以看到入口参数的 oid正好是  16384。

  • 相关阅读:
    bzoj4864 [BeiJing 2017 Wc]神秘物质
    HNOI2011 括号修复
    bzoj2402 陶陶的难题II
    ZJOI2008 树的统计
    USACO09JAN 安全出行Safe Travel
    HAOI2015 树上操作
    hdu5126 stars
    BOI2007 Mokia 摩基亚
    SDOI2011 拦截导弹
    国家集训队 排队
  • 原文地址:https://www.cnblogs.com/gaojian/p/3103692.html
Copyright © 2011-2022 走看看