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. ...
随机推荐
- hdu4638Group
http://acm.hdu.edu.cn/showproblem.php?pid=4638 求某一区间所包含的连续的段 对于乱序的数 到了i这个数所包含的段数 首先把这个数看作单独的段 再看一下前面 ...
- poj 3087 Shuffle'm Up ( map 模拟 )
题目:http://poj.org/problem?id=3087 题意:已知两堆牌s1和s2的初始状态, 其牌数均为c,按给定规则能将他们相互交叉组合成一堆牌s12,再将s12的最底下的c块牌归为s ...
- 解决iframe缓存
网上能搜到很多此类的资料,但都是互相转载,不太起作用.这几天写个用到,用了不少的iframe效果.结果发现iframe有缓存的问题.网上提供了思路,即对iframe的href后添加随即get值,来逃避 ...
- html语意化标签
一.布局的理解误区 网络上流行管新型的布局方式叫“DIV+CSS”,其实是一个错误的理解,导致了很多人过度依赖 与滥用DIV标签, HTML提供了我们一共七八十个标签,其中常用的有三十个左右,DIV不 ...
- (五)学习JavaScript之firstChild 属性
参考:http://www.w3school.com.cn/jsref/prop_node_firstchild.asp 定义和用法 firstChild 属性返回指定节点的首个子节点,以 Node ...
- C# 中的 ref 和 out 的意义和使用方法
原文C# 中的 ref 和 out 的意义和使用方法 向方法传递一个实参时,对应的形参会用实参的一个副本来初始化,不管形参是值类型(例如 int),可空类型(int?),还是引用类型,这一点都是成立的 ...
- 使用VS2010调用matlab的mat格式文件
做实验需要将matlab实现的meanshift的结果中的region的Iabels矩阵,需要把labels.mat读入VS2010中,实现功能,在此把实现过程记录下来. C++读取mat文件的步骤如 ...
- java jvm学习笔记四(安全管理器)
欢迎装载请说明出处:http://blog.csdn.net/yfqnihao 前面已经简述了java的安全模型的两个组成部分(类装载器,class文件校验器),接下来学习的是java安全模型的另外一 ...
- 【译】 AWK教程指南 10编写可与用户交互的AWK程序
执行awk程序时,awk会自动从文件中读取数据来进行处理,直到文件结束.只要将awk读取数据的来源改成键盘输入,便可设计与awk 交互的程序.本节将提供一个该类程序的范例. 范例:本节将编写一个英语生 ...
- bzoj 3110 [Zjoi2013]K大数查询(树套树)
Description 有N个位置,M个操作.操作有两种,每次操作如果是1 a b c的形式表示在第a个位置到第b个位置,每个位置加入一个数c如果是2 a b c形式,表示询问从第a个位置到第b个位置 ...