Parameterized Path 的例子
Improve the planner's ability to use nested loops with inner index scans (Tom Lane) The new "parameterized path" mechanism allows inner index scans to use values from relations that are more than one join level up from the scan. This can greatly improve performance in situations where semantic restrictions (such as outer joins) limit the allowed join orderings.
http://www.postgresql.org/docs/current/static/release-9-2.html
数据准备:
postgres=# create table tst01(id integer);
CREATE TABLE
postgres=# postgres=# insert into tst01 values(generate_series(,));
INSERT
postgres=# postgres=# create index idx_tst01_id on tst01(id);
CREATE INDEX
postgres=#
运行:
postgres=# prepare s(int) as select * from tst01 t where id < $;
PREPARE
postgres=# explain execute s();
QUERY PLAN
---------------------------------------------------------------------------------
Index Only Scan using idx_tst01_id on tst01 t (cost=0.00..8.38 rows= width=)
Index Cond: (id < )
( rows) postgres=# explain execute s();
QUERY PLAN
---------------------------------------------------------------------------------------
Index Only Scan using idx_tst01_id on tst01 t (cost=0.00..337.64 rows= width=)
Index Cond: (id < )
( rows) postgres=# explain execute s();
QUERY PLAN
---------------------------------------------------------------
Seq Scan on tst01 t (cost=0.00..1693.00 rows= width=)
Filter: (id < )
( rows) postgres=# explain execute s();
QUERY PLAN
---------------------------------------------------------------
Seq Scan on tst01 t (cost=0.00..1693.00 rows= width=)
Filter: (id < )
( rows) postgres=#
这是一个小例子,而且还是一个有些特殊的例子。
对比一下在PostgreSQL9.1.0中的表现:
postgres=# create table tst01(id integer);
CREATE TABLE
postgres=# insert into tst01 values(generate_series(1,100000));
INSERT 0 100000
postgres=# create index idx_tst01_id on tst01(id);
CREATE INDEX
postgres=# prepare s(int) as select * from tst01 t where id < $1;
PREPARE
postgres=# explain execute s(2);
QUERY PLAN --------------------------------------------------------------------------------
-
Bitmap Heap Scan on tst01 t (cost=626.59..1486.25 rows=33333 width=4)
Recheck Cond: (id < $1)
-> Bitmap Index Scan on idx_tst01_id (cost=0.00..618.26 rows=33333 width=0)
Index Cond: (id < $1)
(4 rows) postgres=# explain execute s(10000);
QUERY PLAN --------------------------------------------------------------------------------
-
Bitmap Heap Scan on tst01 t (cost=626.59..1486.25 rows=33333 width=4)
Recheck Cond: (id < $1)
-> Bitmap Index Scan on idx_tst01_id (cost=0.00..618.26 rows=33333 width=0)
Index Cond: (id < $1)
(4 rows) postgres=#
可以看到,在9.1里,是不区分状况,执行计划固定。
Parameterized Path 的例子的更多相关文章
- 像画笔一样慢慢画出Path的三种方法(补充第四种)
今天大家在群里大家非常热闹的讨论像画笔一样慢慢画出Path的这种效果该如何实现. 北京-LGL 博客号@ligl007发起了这个话题.然后各路高手踊跃发表意见.最后雷叔 上海-雷蒙 博客号@雷蒙之星 ...
- Raphael path 拖动实现
让 Raphael 的 Path 动起来 Raphaël 是一个很实用的线上矢量图操作 Javascript 库.使用简单,一个值得一提的卖点是通过抽象出共同的接口屏蔽了 SVG 和 VML 之间的差 ...
- d3.js path路径
转自:http://www.d3js.cn/?p=68 svg的path标签被称为”可以组成任何形状的形状” SVG Path可以绘制任何形状的图形,包括矩形,圆形,椭圆,折线,多边形,直线,曲线等. ...
- 学ant(2)——path
1.path是ant内置的一种datatype,作用是声明路径之类的东西,在官方的manual中也叫做Path-like Structures,一般是这样声明的 <pathelement loc ...
- PostgreSQL的prepare 和 execute 动作背后
我给PostgreSQL的源代码加入了调试信息以后,会有如下表现: 我执行Prepare: postgres=# prepare s(; PREPARE postgres=# 背后的反应: ** In ...
- python对文件的操作
一.python中对文件.文件夹操作时经常用到的os模块和shutil模块常用方法. 1.得到当前工作目录,即当前Python脚本工作的目录路径: os.getcwd() 2.返回指定目录下的所有文件 ...
- requirejs:模块加载(require)及定义(define)时的路径小结
原文地址:http://www.tuicool.com/articles/7JBnmy 接触过requirejs的童鞋可能都知道,无论是通过define来定义模块,还是通过require来加载模块,模 ...
- docker好文收藏
深入浅出Docker(一):Docker核心技术预览 2. 核心技术预览 Docker核心是一个操作系统级虚拟化方法, 理解起来可能并不像VM那样直观.我们从虚拟化方法的四个方面:隔离性.可配额/可度 ...
- requirejs:让人迷惑的路径解析
接触过requirejs的童鞋可能都知道,无论是通过define来定义模块,还是通过require来加载模块,模块依赖声明都是很重要的一步.而其中涉及到的模块路径解析,对于新手来说,有的时候会让人觉得 ...
随机推荐
- android 引用 project以及下拉刷新开源类库Android-PullToRefresh 的使用
Android-PullToRefresh 是一个github上的开源下拉刷新类库, GitHub .此外,该作者还有另外一个实用度和关注量极高的项目–另一种Android ActionBar的实现 ...
- Area of a Circle
Area of a Circle Description: Complete the function circleArea so that it will return the area of a ...
- 结构体buf_chunk_t
/** Buffer pool chunk comprising buf_block_t */ typedef struct buf_chunk_struct buf_chunk_t; /** A c ...
- KindEditor设置为过滤模式,但在代码模式下提交表单时不过虑HTML标签的解决方法
KindEditor设置filterMode为true,但在代码模式下提交表单的话,发现并没有过虑掉自己不想保留的HTML标签. 这时只需同步内容前加上红色部分内容即可: onClick=" ...
- 记录遇到的IE8兼容性问题汇总
1,伪元素:first-child不起作用,需要单独指定样式名称 2,透明度表示方法,尤其在函数中表示 @mixin opacity($value) { -webkit-opacity: $value ...
- POJ 2398 Toy Storage
这道题和POJ 2318几乎是一样的. 区别就是输入中坐标不给排序了,=_=|| 输出变成了,有多少个区域中有t个点. #include <cstdio> #include <cma ...
- Azure 负载平衡器新分发模式
Yves Pitsch Azure 网络首席项目经理 Azure负载平衡器是一种第四层(TCP.UDP)类型的负载平衡器,它可以将传入流量分发到云服务中正常运行的服务实例上,或者分发到负载平衡器集内所 ...
- 2、Android应用程序基本特性
1. apk是android应用程序安装格式,.dex是Android二进制执行文件格式. 2.Android操作系统是基于Linux的多用户操作系统,每一个应用程序都是使用的不同的用户. 3. 默认 ...
- alibaba笔试3
16.C 17.这道的取值范围应该是1到1023.这样就选择A 18.B 圆桌问题1个人拿出来当key 19.D 类似于https://apollozhao.wordpress.com/categor ...
- Live555研究之三 RTSP Server处理请求
RTSP Server会不断用select查询是否有socket连接,如果有则在(*handler->handlerProc)(handler->clientData, resultCon ...