SELECT COUNT (*) FROM rps2_workflow WHERE workflow_added > TO_DATE ('01.09.2011','dd.mm.yyyy') AND workflow_finished < TO_DATE ('wtf','dd.mm.yyyy') AND workflow_status IN (7,12,17) AND workflow_worker = 159
我期望此查询失败,因为日期无效,但返回0
8 TABLE ACCESS BY INDEX ROWID TABLE RPS2.RPS2_WORKFLOW Object Instance: 1 Filter Predicates: ("WORKFLOW_STATUS"=7 OR "WORKFLOW_STATUS"=12 OR "WORKFLOW_STATUS"=17) AND SYS_EXTRACT_UTC("WORKFLOW_FINISHED")<SYS_EXTRACT_UTC(TO_DATE('wtf','dd.mm.yyyy')) Cost: 11 Bytes: 33 Cardinality: 1 cpu Cost: 8 M IO Cost: 10 Time: 1
如果我们注释了AND workflow_status IN(7,17)条件 – 那么我们预期得到ORA-01858:找到一个非数字字符,其中有一个数字
如果我们注释出“工作流程_ TO_DATE(‘wtf’,’dd.mm.yyyy’)然后我们获得适合该条件的记录数量(> 0)
这怎么可能?
UPD:
提示/ * no_index(rps2_workflow)* /不会更改任何内容(而在计划中,我们看到执行了全扫描)
SELECT STATEMENT ALL_ROWSCost: 254 Bytes: 31 Cardinality: 1 cpu Cost: 34 M IO Cost: 248 Time: 4 2 SORT AGGREGATE Bytes: 31 Cardinality: 1 1 TABLE ACCESS FULL TABLE RPS2.RPS2_WORKFLOW Object Instance: 1 Filter Predicates: "WORKFLOW_WORKER"=159 AND ("WORKFLOW_STATUS"=7 OR "WORKFLOW_STATUS"=12 OR "WORKFLOW_STATUS"=17) AND SYS_EXTRACT_UTC("WORKFLOW_ADDED")>SYS_EXTRACT_UTC(TIMESTAMP' 2011-09-01 00:00:00') AND SYS_EXTRACT_UTC("WORKFLOW_FINISHED")<SYS_EXTRACT_UTC(TO_DATE('wtf','dd.mm.yyyy')) Cost: 254 Bytes: 31 Cardinality: 1 cpu Cost: 34 M IO Cost: 248 Time: 4
解决方法
它可能发现满足所有其他条件的每个记录都有一个NULL工作流程完成字段.
而与NULL相比,任何事情都是未知的,所以它不需要评估另一个操作数.