最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
PostgreSQL子查询优化详解
时间:2022-06-29 10:21:28 编辑:袖梨 来源:一聚教程网
1.2.2 PostgreSQL
1.2.2.1 S6 语句
查看查询执行计划,子查询被优化(采用物化的方式,使得子查询结果被缓存,既子查询只执行一次)。
postgres=# EXPLAIN SELECT * FROM t3 WHERE b3 >= ANY (SELECT b1 FROM t1);
Nested Loop Semi Join (cost=0.00..41707.39 rows=680 )
Join Filter: (t3.b3 >= t1.b1)
-> Seq Scan on t3 (cost=0.00..30.40 rows=2040 )
-> Materialize (cost=0.00..40.60 rows=2040 )
-> Seq Scan on t1 (cost=0.00..30.40 rows=2040 )
1.2.2.2 S7 语句
查看查询执行计划,子查询被优化(采用半连接)。
postgres=# EXPLAIN SELECT * FROM t3 WHERE b3 >= ANY (SELECT a1 FROM t1);
Nested Loop Semi Join (cost=0.15..377.82 rows=680 )
-> Seq Scan on t3 (cost=0.00..30.40 rows=2040 )
-> Index Only Scan using t1_a1_key on t1 (cost=0.15..12.08 rows=680 )
Index Cond: (a1 <= t3.b3)
1.2.2.3 S8 语句
查看查询执行计划,子查询被优化(采用半连接)。
postgres=# EXPLAIN SELECT * FROM t3 WHERE b3 <= SOME (SELECT a1 FROM t1);
Nested Loop Semi Join (cost=0.15..377.82 rows=680 )
-> Seq Scan on t3 (cost=0.00..30.40 rows=2040 )
-> Index Only Scan using t1_a1_key on t1 (cost=0.15..12.08 rows=680 )
Index Cond: (a1 >= t3.b3)
1.2.2.4 S9 语句
查看查询执行计划,子查询被优化。
postgres=# EXPLAIN SELECT * FROM t3 WHERE b3 = SOME (SELECT a1 FROM t1);
Hash Semi Join (cost=55.90..103.00 rows=1020 )
Hash Cond: (t3.b3 = t1.a1)
-> Seq Scan on t3 (cost=0.00..30.40 rows=2040 )
-> Hash (cost=30.40..30.40 rows=2040 )
-> Seq Sc
相关文章
- 《彩色点点战争》推图常用三大主c玩法详解 01-23
- 《燕云十六声》池鱼林木任务攻略 01-23
- 《大连地铁e出行》查看行程记录方法 01-23
- 《明日方舟》2025春节限定干员余角色介绍 01-23
- 《崩坏:星穹铁道》万敌光锥搭配攻略 01-23
- 《燕云十六声》一药千金任务攻略 01-23