PostgreSQL查询计划中的路径-BitmapHeapPath-辨析(二)
来源:互联网 发布:如何对待网络语言 编辑:程序博客网 时间:2024/06/07 01:27
create table t5(a int, b int);
create table t6(a int, b int);
insert into t5 values(generate_series(1,10000,1), generate_series(2,20000,2));
insert into t6 values(generate_series(1,10000,1), generate_series(2,20000,2));
create unique index I_t5 on t5 (a);
create unique index I_t6 on t6 (b);
test=# explain select V1.a, V2.b from t5 V1, t6 v2 where (V1.a=V2.b and V1.b=V2.
a) or (V1.a=5000 and V2.b=5000);
QUERY PLAN
-----------------------------------------------------------------------------------------
Nested Loop (cost=0.54..46164.00 rows=2 width=8)
Join Filter: (((v1.a = v2.b) AND (v1.b = v2.a)) OR ((v1.a = 5000) AND (v2.b = 5000)))
-> Seq Scan on t5 v1 (cost=0.00..145.00 rows=10000 width=8)
-> Bitmap Heap Scan on t6 v2 (cost=0.54..4.56 rows=2 width=8)
Recheck Cond: ((v1.a = b) OR (b = 5000))
-> BitmapOr (cost=0.54..0.54 rows=2 width=0)
-> Bitmap Index Scan on i_t6 (cost=0.00..0.27 rows=1 width=0)
Index Cond: (v1.a = b)
-> Bitmap Index Scan on i_t6 (cost=0.00..0.27 rows=1 width=0)
Index Cond: (b = 5000)
(10 rows)
test=# explain select V1.a, V2.b from t5 V1, t6 v2 where (V1.a=V2.b or V1.b=V2.a
) and (V1.a=5000 or V2.b=5000);
QUERY PLAN
----------------------------------------------------------------------------------------
Nested Loop (cost=0.00..2250315.00 rows=4 width=8)
Join Filter: (((v1.a = v2.b) OR (v1.b = v2.a)) AND ((v1.a = 5000) OR (v2.b =5000)))
-> Seq Scan on t5 v1 (cost=0.00..145.00 rows=10000 width=8)
-> Materialize (cost=0.00..195.00 rows=10000 width=8)
-> Seq Scan on t6 v2 (cost=0.00..145.00 rows=10000 width=8)
(5 rows)
create table t6(a int, b int);
insert into t5 values(generate_series(1,10000,1), generate_series(2,20000,2));
insert into t6 values(generate_series(1,10000,1), generate_series(2,20000,2));
create unique index I_t5 on t5 (a);
create unique index I_t6 on t6 (b);
test=# explain select V1.a, V2.b from t5 V1, t6 v2 where (V1.a=V2.b and V1.b=V2.
a) or (V1.a=5000 and V2.b=5000);
QUERY PLAN
-----------------------------------------------------------------------------------------
Nested Loop (cost=0.54..46164.00 rows=2 width=8)
Join Filter: (((v1.a = v2.b) AND (v1.b = v2.a)) OR ((v1.a = 5000) AND (v2.b = 5000)))
-> Seq Scan on t5 v1 (cost=0.00..145.00 rows=10000 width=8)
-> Bitmap Heap Scan on t6 v2 (cost=0.54..4.56 rows=2 width=8)
Recheck Cond: ((v1.a = b) OR (b = 5000))
-> BitmapOr (cost=0.54..0.54 rows=2 width=0)
-> Bitmap Index Scan on i_t6 (cost=0.00..0.27 rows=1 width=0)
Index Cond: (v1.a = b)
-> Bitmap Index Scan on i_t6 (cost=0.00..0.27 rows=1 width=0)
Index Cond: (b = 5000)
(10 rows)
test=# explain select V1.a, V2.b from t5 V1, t6 v2 where (V1.a=V2.b or V1.b=V2.a
) and (V1.a=5000 or V2.b=5000);
QUERY PLAN
----------------------------------------------------------------------------------------
Nested Loop (cost=0.00..2250315.00 rows=4 width=8)
Join Filter: (((v1.a = v2.b) OR (v1.b = v2.a)) AND ((v1.a = 5000) OR (v2.b =5000)))
-> Seq Scan on t5 v1 (cost=0.00..145.00 rows=10000 width=8)
-> Materialize (cost=0.00..195.00 rows=10000 width=8)
-> Seq Scan on t6 v2 (cost=0.00..145.00 rows=10000 width=8)
(5 rows)
0 0
- PostgreSQL查询计划中的路径-BitmapHeapPath-辨析(二)
- PostgreSQL查询计划中的路径-BitmapHeapPath-辨析
- PostgreSQL的查询语句的连接方式与查询计划比较--多表连接(二)
- PostgreSQL查询代价估算(二)
- PostgreSQL中的模糊查询
- PostgreSQL 查询计划时间的计算详解
- PostgreSQL的查询语句的连接方式与查询计划比较--多表连接(一)
- PostgreSQL的查询语句的连接方式与查询计划比较--多表连接(三)
- PostgreSQL源码修改 ——查询优化(二)
- PostgreSQL源码修改 ——查询优化(二)
- tcp-h数据&postgresql查询(数据库学习之二)
- PostgreSQL查询优化器--逻辑查询优化--子查询优化(二)
- PostgreSQL服务过程中的那些事二:Pg服务进程处理简单查询梗概
- PostgreSQL服务过程中的那些事二:Pg服务进程处理简单查询一:开启事务
- MySQL执行计划辨析--子查询的相关显示项的含义
- PostgreSQL查询优化器--逻辑查询优化--视图优化(二)
- PostgreSQL服务过程中的那些事二:Pg服务进程处理简单查询二:SQL解析为parsetree
- 查询PostgreSQL中的数据库是否存在
- ubuntu16.04中将python3设置为默认
- MySQL查询优化器--逻辑查询优化技术(五)--外连接的消除(二)
- Jquery.Pagination分页插件的学习
- windows10下安装ubuntu16.04 双系统
- tensorflow学习笔记三:实例数据下载与读取
- PostgreSQL查询计划中的路径-BitmapHeapPath-辨析(二)
- 深度学习框架的评估与比较
- MySQL查询优化器--逻辑查询优化技术(六)--条件化简(表达式处理)
- Deep learning与Neural Network
- MySQL查询优化器--逻辑查询优化技术(七)--等价谓词重写
- ACM无穷常数的设置
- Linux网络编程——端口复用(多个套接字绑定同一个端口)
- MySQL查询优化器--语义优化(一)
- Python基础教程笔记 第一章