引用 4 楼 的回复:
看了一下解释计划,上面语句慢的原因是:
select * from tableA where id in (select aid from tableB where name in ('123')) or 1=0会执行全表扫描,但select * from tableA where id in (select aid from tableB where name i……
[/Quote]
我是9i的,10g的没测过。。。
[Quote=引用 4 楼 的回复:]
看了一下解释计划,上面语句慢的原因是:
select * from tableA where id in (select aid from tableB where name in ('123')) or 1=0会执行全表扫描,但select * from tableA where id in (select aid from tableB where name in ('123'))这句就不……
[/Quote]
你的Oracle版本是不是有问题?我10G的版本上测试了下,两者写法的解释计划完全一样,遇到OR 1=0会直接忽略此条件的。
看了一下解释计划,上面语句慢的原因是:
select * from tableA where id in (select aid from tableB where name in ('123')) or 1=0会执行全表扫描,但select * from tableA where id in (select aid from tableB where name in ('123'))这句就不会进行全表扫描,怎么办啊