小编use*_*956的帖子

隐式连接与 Postgres 中的显式连接一样有效吗?

通常这样写很方便:

SELECT * 
FROM t1   # ... +many more tables
INNER JOIN t2 ON (t1.id = t2.col)
INNER JOIN t3 ON (t1.id = t3.col)
INNER JOIN t4 ON (t1.id = t4.col)
...
Run Code Online (Sandbox Code Playgroud)

作为带条件的交叉连接:

SELECT * 
FROM t1, t2, t3, t4   # ... +many more tables
WHERE
       t1.id = t2.col
   AND t1.id = t3.col
   AND t1.id = t4.col
   # +include matches on columns of other tables
Run Code Online (Sandbox Code Playgroud)

但是,交叉连接的简单实现将比内部连接具有更高的时间复杂度。Postgres 是否将第二个查询优化为与第一个查询具有相同时间复杂度的查询?

postgresql join execution-plan

2
推荐指数
1
解决办法
2444
查看次数

标签 统计

execution-plan ×1

join ×1

postgresql ×1