博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PostgreSQL在何处处理 sql查询之五十八
阅读量:5265 次
发布时间:2019-06-14

本文共 2835 字,大约阅读时间需要 9 分钟。

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

/* *     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效果呢

转载于:https://www.cnblogs.com/gaojian/archive/2013/06/10/3130693.html

你可能感兴趣的文章
Entityframework:“System.Data.Entity.Internal.AppConfig”的类型初始值设定项引发异常。...
查看>>
Linux中防火墙centos
查看>>
mysql新建用户,用户授权,删除用户,修改密码
查看>>
FancyCoverFlow
查看>>
JS博客
查看>>
如何设置映射网络驱动器的具体步骤和方法
查看>>
ASP.NET WebApi 基于OAuth2.0实现Token签名认证
查看>>
283. Move Zeroes把零放在最后面
查看>>
Visual Studio Code 打开.py代码报Linter pylint is not installed解决办法
查看>>
Python 数据类型
查看>>
centos下同时启动多个tomcat
查看>>
slab分配器
查看>>
【读书笔记】C#高级编程 第三章 对象和类型
查看>>
针对sl的ICSharpCode.SharpZipLib,只保留zip,gzip的流压缩、解压缩功能
查看>>
【SVM】libsvm-python
查看>>
Jmeter接口压力测试,Java.net.BindException: Address already in use: connect
查看>>
Leetcode Balanced Binary Tree
查看>>
go:channel(未完)
查看>>
[JS]递归对象或数组
查看>>
LeetCode(17) - Letter Combinations of a Phone Number
查看>>