PostgreSQL的prepare 和 execute 动作背后
我给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 动作背后的更多相关文章
- PHP PDO prepare()、execute()和bindParam()方法详解
每次将查询发送给MySQL服务器时,都必须解析该查询的语法,确保结构正确并能够执行.这是这个过程中必要的步骤,但也确实带来了一些开销.做一次是必要的,但如果反复地执行相同的查询,批量插入多行并只改变列 ...
- mysql之预处理语句prepare、execute、deallocate
预制语句的SQL语法基于三个SQL语句: PREPARE stmt_name FROM preparable_stmt; EXECUTE stmt_name [USING @var_name [, @ ...
- MySQL 预处理语句prepare、execute、deallocate的使用
所以对于中文乱码,需要去check的地方有如下3个:1.mysql窗口的字符编码(xshell连接的远程工具的字符集设置):2.数据库的字符编码(show variables like '%char% ...
- Mysql预处理语句prepare、execute、deallocate
前言 做CTF题的时候遇到的所以参考资料学习一波.... MySQL的SQL预处理(Prepared) 一.SQL 语句的执行处理 1.即时 SQL 一条 SQL 在 DB 接收到最终执行完毕返回,大 ...
- 强网杯 2019]随便注(堆叠注入,Prepare、execute、deallocate)
然后就是今天学的新东西了,堆叠注入. 1';show databases; # 1';show tables; # 发现两个表1919810931114514.words 依次查询两张表的字段 1'; ...
- PostgreSQL.conf文件配置详解[转]
一.连接配置与安全认证 1.连接Connection Settings listen_addresses (string) 这个参数只有在启动数据库时,才能被设置.它指定数据库用来监听客户端连接的 ...
- PostgreSQL 9.5 高可用、负载均衡和复制
高可用.负载均衡和复制 1. 不同方案的比较 共享磁盘故障转移 共享磁盘故障转移避免了只使用一份数据库拷贝带来的同步开销. 它使用一个由多个服务器共享的单一磁盘阵列.文件系统(块设备)复制 DRBD是 ...
- Java向PostgreSQL发送prepared statement 与 libpq 向PostgreSQL发送prepared statement之比较:
Java 代码,在数据库端,并没有当成 prepared statetment 被处理. C代码通过libpq 访问数据库端,被当成了 prepared statement 处理.也许是因Postgr ...
- Cause: org.postgresql.util.PSQLException: ERROR: cached plan must not change result type的前因后果
首先说明一下遇到的问题: PG数据库,对其中的某张表增加一列后,应用报错,信息如下: 应用使用相关框架如下:SpringBoot.MyBatis. ### Cause: org.postgresql. ...
随机推荐
- linux地址映射1、2、3(☆☆☆)
欢迎关注瘋耔新浪微博:http://weibo.com/cpjphone 一.线性映射与非线性映射 ...
- [原]Unity3D深入浅出 - 摄像机组件(Camera)
在Unity中创建一个Camera后,除了默认带一个Transform组件外,还会附带Flare Layer.GUI Layer.Audio Listener等4个组件,如下图. ClearFlags ...
- [POJ 3370] Halloween treats
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7143 Accepted: 2641 ...
- Spring中使用quartz插件实现定时任务
第一步:导入架包 *spring3.2.3版本的架包将spring的各个功能模块给分开了,我们必须将Spring必须依赖的包导入上去 第二步:编写配置文件 <?xml version=" ...
- 中国Azure媒体服务RESTAPI的Endpoint
Amber Zhao Thu, Feb 26 2015 4:09 AM 由于海外Azure和中国Azure有不同的domain,很多用户在使用媒体服务RESTAPI时,需要指定中国Azure媒体服务 ...
- Java [Leetcode 40]Combination Sum II
题目描述: Given a collection of candidate numbers (C) and a target number (T), find all unique combinati ...
- java中正则表达式
在<java编程思想>中,java中的 \\ 表示“我要插入一个正则表达式的反斜线,所以其后的字符具有特殊的意义.”如果想插入一个普通的反斜线,那么应该使用 \\\\. 理解: 我们使用的 ...
- java语言实现简单接口工具--粗简版
2016注定是变化的一年,忙碌.网红.项目融资失败,现在有点时间整整帖子~~ 目标: 提高工作效率与质量,能支持平台全量接口回归测试与迭代测试也要满足单一接口联调测试. 使用人员: 测试,开发 工具包 ...
- iBatis之type
iBatis下关于type的UML图,展示iBatis下关于类型的处理和注册等.
- iOS7程序后台运行
介绍 这次 iOS7 对程序后台运行进行了加强,但是仅仅是加强而已,要想像 Android 程序那样自由当然就别想了,苹果这么做主要还是出于电池使用时间考虑,但是这次的加强对大部分程序基本够用. 在介 ...