oracle中where子句中的多个条件的顺序

时间:2016-08-11 10:40:04

标签: oracle

我正在尝试了解如何在' where子句'中执行多个条件,如果我查询表格,并且在where条件中我是否已使用'和'运算符如果我对列有一些简单的过滤条件,那么再次选择查询,这是最短的时间。

执行1.17秒:

SELECT count(col1) FROM table1 idbs WHERE TRUNC(idbs.DATE) BETWEEN TO_DATE('01/01/2000','mm/dd/yyyy') AND TO_DATE('08/11/2016','mm/dd/yyyy') and COL2 <> 'Y' AND COL3 = 'N' AND COL4 <> 36 AND (var IS NULL OR idbs.COL5 IN( (SELECT regexp_substr(var,'[^|]+', 1, LEVEL) FROM dual CONNECT BY regexp_substr(var,'[^|]+', 1, LEVEL) IS NOT NULL)));

以下查询执行时间为1.207秒:

SELECT count(col1) FROM table1 idbs WHERE COL2 <> 'Y' AND COL3 = 'N' AND COL4 <> 36 AND TRUNC(idbs.DATE) BETWEEN TO_DATE('01/01/2000','mm/dd/yyyy') AND TO_DATE('08/11/2016','mm/dd/yyyy') AND (var IS NULL OR idbs.COL5 IN( (SELECT regexp_substr(var,'[^|]+', 1, LEVEL) FROM dual CONNECT BY regexp_substr(var,'[^|]+', 1, LEVEL) IS NOT NULL))) ;

我刚刚重新安排了条件,但我在执行后看到的时间略有不同。

0 个答案:

没有答案