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。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值