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

    看到了其源代码中的一段注释,似乎认识又提高了一层:

    /*
     *     INTERFACE ROUTINES
     *        ExecInitNode    -        initialize a plan node and its subplans
     *        ExecProcNode    -        get a tuple by executing the plan node
     *        ExecEndNode        -        shut down a plan node and its subplans
     *
     *     NOTES
     *        This used to be three files.  It is now all combined into
     *        one file so that it is easier to keep ExecInitNode, ExecProcNode,
     *        and ExecEndNode in sync when new nodes are added.
     *
     *     EXAMPLE
     *        Suppose we want the age of the manager of the shoe department and
     *        the number of employees in that department.  So we have the query:
     *
     *                select DEPT.no_emps, EMP.age
     *                where EMP.name = DEPT.mgr and
     *                      DEPT.name = "shoe"
     *
     *        Suppose the planner gives us the following plan:
     *
     *                        Nest Loop (DEPT.mgr = EMP.name)
     *                        /        \
     *                       /         \
     *                   Seq Scan        Seq Scan
     *                    DEPT          EMP
     *                (name = "shoe")
     *
     *        ExecutorStart() is called first.
     *        It calls InitPlan() which calls ExecInitNode() on
     *        the root of the plan -- the nest loop node.
     *
     *      * ExecInitNode() notices that it is looking at a nest loop and
     *        as the code below demonstrates, it calls ExecInitNestLoop().
     *        Eventually this calls ExecInitNode() on the right and left subplans
     *        and so forth until the entire plan is initialized.    The result
     *        of ExecInitNode() is a plan state tree built with the same structure
     *        as the underlying plan tree.
     *
     *      * Then when ExecutorRun() is called, it calls ExecutePlan() which calls
     *        ExecProcNode() repeatedly on the top node of the plan state tree.
     *        Each time this happens, ExecProcNode() will end up calling
     *        ExecNestLoop(), which calls ExecProcNode() on its subplans.
     *        Each of these subplans is a sequential scan so ExecSeqScan() is
     *        called.  The slots returned by ExecSeqScan() may contain
     *        tuples which contain the attributes ExecNestLoop() uses to
     *        form the tuples it returns.
     *
     *      * Eventually ExecSeqScan() stops returning tuples and the nest
     *        loop join ends.  Lastly, ExecutorEnd() calls ExecEndNode() which
     *        calls ExecEndNestLoop() which in turn calls ExecEndNode() on
     *        its subplans which result in ExecEndSeqScan().
     *
     *        This should show how the executor works by having
     *        ExecInitNode(), ExecProcNode() and ExecEndNode() dispatch
     *        their work to the appopriate node support routines which may
     *        in turn call these routines themselves on their subplans.

    那么,我能否一定制造出 Nest Loop效果呢

  • 相关阅读:
    让WPF的Popup不总置顶的解决方案
    virtio 驱动的数据结构理解
    关于Linux下面msyql安装后并未设置初始密码,但是登录报错“Access denied for user 'root'@'localhost' (using password: NO)”的解决方案
    gulp初涉
    前后端分离--构建前端Mock Server--windows部署rap
    一些css小用法总结(持续更新~)
    js原生封装自定义滚动条
    ie下面兼容性问题的一些总结
    关于html水平垂直居中的一些总结吧
    C# 正则表达式匹配string字符串中的时间串(yyyyMMdd)
  • 原文地址:https://www.cnblogs.com/gaojian/p/3130693.html
Copyright © 2011-2022 走看看