Amazon Redshift 中的 WHERE EXISTS 与 IN [英] WHERE EXISTS vs IN in Amazon Redshift

查看:19
本文介绍了Amazon Redshift 中的 WHERE EXISTS 与 IN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Amazon Redshift 中对同一查询的两个版本运行 EXPLAIN:

I run EXPLAIN on two versions of the same query in Amazon Redshift:

SELECT t1.column
FROM table1 t1
WHERE t1.column IN
(SELECT t2.column FROM table2 t2);

SELECT t1.column
FROM table1 t1
WHERE EXISTS
(SELECT 1 FROM table2 t2 WHERE t1.column = t2.column );

他们似乎有相同的查询计划.这是否意味着 IN 和 WHERE EXISTS 之间没有性能差异,因为 Redshift 在编译查询之前以某种方式优化了 SQL 输入?

They seem to have the same query plan. Does that mean that there is no performance difference between IN and WHERE EXISTS as Redshift somehow optimizes the SQL input before compiling the query?

推荐答案

如果两个查询具有相同的计划,则 Redshift 可能会在后面重写它以优化其中一个或两个语句.

If both queries have the same plan, it is possible Redshift is rewriting it in the back to optimize one of them, or both statements.

这篇关于Amazon Redshift 中的 WHERE EXISTS 与 IN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆