In子句与OR子句的性能明智 [英] In clause versus OR clause performance wise

查看:89
本文介绍了In子句与OR子句的性能明智的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个如下查询:

select * 
from table_1 
where column_name in ('value1','value2','value3');

考虑到这样一个表中的数据可能是数百万,下面的重组会更好吗?

considering that the data in such a table may be in millions, will the below restructuring help better??

select * 
from table_1 where 
column_name = 'value1' 
or column_name = 'value2' 
or column_name ='value3';

select * 
from table_1 
where column_name = any ('value1','value2','value3');

如果可能,我还需要知道性能上的好处.

I need to know performance benefits also if possible.

预先感谢

推荐答案

仅对3个值进行检查,查询并不重要.

the query doesn't matter much in case of 3 value checking only.

Oracle仍将重新编写查询以匹配可用的最佳选项.

Oracle will re-write the query anyways to match the best option available.

如果有更多的值并且过于动态,则in子句或内部联接可能会更好.

in case there were more values and that too dynamic then the in clause or inner join could have been better.

最好让查询保持当前状态

its best to leave the query as it is currently

这篇关于In子句与OR子句的性能明智的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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