我给PostgreSQL的源代码加入了调试信息以后,会有如下表现:

我执行Prepare:

postgres=# prepare s(int) as select * from tst01 t where id < $;
PREPARE
postgres=#

背后的反应:

** In PostgresMain
In exec_simple_query loop for parsetree_list++++++++++++++++++++++++++Before pg_plan_queries
***************In pg_plan_queries -------start
................In pg_plan_queries...query->commandType == CMD_UTILITY
***************In pg_plan_queries -------end
In exec_simple_query loop for parsetree_list++++++++++++++++++++++++++After pg_plan_queries ...In exec_simple_query....Before PortalRun
.....In PortalRun ------------start
.......In PortalRunUtility ---------------start
.........In ProcessUtility----Start
.........In ProcessUtility----End
.......In PortalRunUtility ---------------end
.....In PortalRun ------------end
...In exec_simple_query....After PortalRun

接着执行 Execute:

postgres=# execute s();
id
---- ( row) postgres=#

背后的反应:

In exec_simple_query loop for parsetree_list++++++++++++++++++++++++++Before pg_plan_queries
***************In pg_plan_queries -------start
................In pg_plan_queries...query->commandType == CMD_UTILITY
***************In pg_plan_queries -------end
In exec_simple_query loop for parsetree_list++++++++++++++++++++++++++After pg_plan_queries ...In exec_simple_query....Before PortalRun
.....In PortalRun ------------start
xxxxxxIn FillPortalStore ...........start
.......In PortalRunUtility ---------------start
.........In ProcessUtility----Start
..........In standard_ProcessUtility ... Before ExecuteQuery
xxxxxxxxxxxIn ExecuteQuery--------start
++++++++++++In GetCachedPlan ........start
.............In BuildCachedPlan, Before pg_plan_queries
***************In pg_plan_queries -------start
................In pg_plan_queries...query->commandType != CMD_UTILITY
..................In pg_plan_query........start
*******************In planner ........start
___________________In standard_planner........start
********************In subquery_planner........start
++++++++++++++++++++++In grouping_planner......start
************************In query_planner......start
........................In make_one_rel......start
...........................In set_base_rel_pathlists......start
-----------------------------In set_rel_pathlist......start
******************************In set_plain_rel_pathlist......start
-------------------------------Before add_path of seqscan
-------------------------------After add_path of seqscan -------------------------------Before create_index_paths
-------------------------------After create_index_path -------------------------------Before create_tidscan_paths
-------------------------------After create_tidscan_paths -------------------------------Before set_cheapest
-------------------------------After set_cheapest ******************************In set_plain_rel_pathlist......end
-----------------------------In set_rel_pathlist......end
...........................In set_base_rel_pathlists......end
........................In make_one_rel......end
************************In query_planner......end
++++++++++++++++++++++In grouping_planner......end
********************In subquery_planner........end
___________________In standard_planner........end
*******************In planner ........end
..................In pg_plan_query........end
***************In pg_plan_queries -------end
.............In BuildCachedPlan, After pg_plan_queries
++++++++++++In GetCachedPlan ........end .....In PortalRun ------------start
.....In PortalRun ------------end
xxxxxxxxxxxIn ExecuteQuery--------end
..........In standard_ProcessUtility ... After ExecuteQuery
.........In ProcessUtility----End
.......In PortalRunUtility ---------------end
xxxxxxIn FillPortalStore ...........end
.....In PortalRun ------------end
...In exec_simple_query....After PortalRun

按照对过去版本的认识,应当是PortalRun的时候单纯执行计划。

但是preapre....execute 方式,把它破坏了。

可以看到,prepare时候,不进行path的生成。

execute 的时候,在PortalRun的阶段,通过 ExecuteQuery->GetCachedPlan->BuildCachedPlan,

来生成path和确定plan。

不过要注意到一点是,我所执行的上述的例子中,并没有导致 param_info 非空。

可以说,这种针对单一表的preapre execute,是把执行计划的生成推后了,但是并不等于它就是 Parameterized Path。

PostgreSQL的prepare 和 execute 动作背后的更多相关文章

  1. PHP PDO prepare()、execute()和bindParam()方法详解

    每次将查询发送给MySQL服务器时,都必须解析该查询的语法,确保结构正确并能够执行.这是这个过程中必要的步骤,但也确实带来了一些开销.做一次是必要的,但如果反复地执行相同的查询,批量插入多行并只改变列 ...

  2. mysql之预处理语句prepare、execute、deallocate

    预制语句的SQL语法基于三个SQL语句: PREPARE stmt_name FROM preparable_stmt; EXECUTE stmt_name [USING @var_name [, @ ...

  3. MySQL 预处理语句prepare、execute、deallocate的使用

    所以对于中文乱码,需要去check的地方有如下3个:1.mysql窗口的字符编码(xshell连接的远程工具的字符集设置):2.数据库的字符编码(show variables like '%char% ...

  4. Mysql预处理语句prepare、execute、deallocate

    前言 做CTF题的时候遇到的所以参考资料学习一波.... MySQL的SQL预处理(Prepared) 一.SQL 语句的执行处理 1.即时 SQL 一条 SQL 在 DB 接收到最终执行完毕返回,大 ...

  5. 强网杯 2019]随便注(堆叠注入,Prepare、execute、deallocate)

    然后就是今天学的新东西了,堆叠注入. 1';show databases; # 1';show tables; # 发现两个表1919810931114514.words 依次查询两张表的字段 1'; ...

  6. PostgreSQL.conf文件配置详解[转]

    一.连接配置与安全认证 1.连接Connection Settings   listen_addresses (string) 这个参数只有在启动数据库时,才能被设置.它指定数据库用来监听客户端连接的 ...

  7. PostgreSQL 9.5 高可用、负载均衡和复制

    高可用.负载均衡和复制 1. 不同方案的比较 共享磁盘故障转移 共享磁盘故障转移避免了只使用一份数据库拷贝带来的同步开销. 它使用一个由多个服务器共享的单一磁盘阵列.文件系统(块设备)复制 DRBD是 ...

  8. Java向PostgreSQL发送prepared statement 与 libpq 向PostgreSQL发送prepared statement之比较:

    Java 代码,在数据库端,并没有当成 prepared statetment 被处理. C代码通过libpq 访问数据库端,被当成了 prepared statement 处理.也许是因Postgr ...

  9. Cause: org.postgresql.util.PSQLException: ERROR: cached plan must not change result type的前因后果

    首先说明一下遇到的问题: PG数据库,对其中的某张表增加一列后,应用报错,信息如下: 应用使用相关框架如下:SpringBoot.MyBatis. ### Cause: org.postgresql. ...

随机推荐

  1. eclipse+pydev (python) 配置出错

    错误: eclipse+pydev 配置出错,就是在选择python interpreter那一步: See error log for details.com.sun.org.apache.xerc ...

  2. js设置datagriad的行移动

    //                    ,//                formatter: function(value,row,index){//                    ...

  3. POJ 2586 Y2K Accounting Bug(贪心)

    题目连接:http://poj.org/problem?id=2586 题意:次(1-5.2-6.3-7.4-8.5-9.6-10.7-11.8-12),次统计的结果全部是亏空(盈利-亏空<0) ...

  4. 最受 Web 开发者欢迎的 NoSQL 和关系数据库

    Web应用离不开数据库,目前市场上有种类繁多数据库可供开发者选择,例如SQL.NoSQL.键值.图谱数据库等等.关于不同数据库在开发者中的受欢迎程度也是仁者见仁智者见智,但是通过统计亚马逊这样的公共云 ...

  5. Vim cscope

    /********************************************************************** * Vim cscope * 说明: * 之前使用Vim ...

  6. POJ 2135 Farm Tour(最小费用最大流,变形)

    题意:给一个无向图,FJ要从1号点出发到达n号点,再返回到1号点,但是路一旦走过了就会销毁(即回去不能经过),每条路长度不同,那么完成这趟旅行要走多长的路?(注:会有重边,点号无序,无向图!) 思路: ...

  7. css的框架——common.css

    @charset "utf-8"; /* 字体 */ .n{ font-weight:normal; font-style:normal; } .b{font-weight:bol ...

  8. .NET 4.0中的泛型协变和逆变

    随Visual Studio 2010 CTP亮相的C#4和VB10,虽然在支持语言新特性方面走了相当不一样的两条路:C#着重增加后期绑定和与动态语言相容的若干特性,VB10着重简化语言和提高抽象能力 ...

  9. selenium 处理iframe

    这篇关于iframe的文章不错 http://assertselenium.com/2013/02/22/handling-iframes-using-webdriver/ selenium处理ifr ...

  10. 《C Primer Plus 第五版》读书笔记

    CH1-2:概述 链接器:链接库代码.启动代码(start-up code) CH3-5:数据.字符串.运算符 1 数据类型存储方式:整数类型.浮点数类型 2 浮点数存储:小数部分+指数部分 3 in ...