我也这么想过,但是不知道是不是唯一的办法. 我试过可以先查出B表的数据如select b.e from b where b.d=(select d from a where ff='123')这样速度很快.这样就可以把它和select a.c from where ff='123'查出来的数据 整合?我记得oracle有函数但是忘了.
用in肯定不行爆慢,没有别的了吗?unite好像只能对同结构的表做关联
用RBO的话,如果表a数据量<<<表b的数据量: 我用select a.c,b.e from b,a where a.d=b.d and ff='123' 即将from里的a,b互换,将数据量小的a表作为driving table. 然后,如果ff='123'能够去掉大量的数据的话,将ff='123'放在 where后的最后一个,这点你没错.
建视图 create view as select a.ff,a.c,b.e,b.d from a,b where a.d=b.d
建个视图就一切OK了,你的数据量也不是很大, create view as select a.c as c,b.e as e from a,b where a.d=b.d and ff='123'
我试过可以先查出B表的数据如select b.e from b where b.d=(select d from a where ff='123')这样速度很快.这样就可以把它和select a.c from where ff='123'查出来的数据
整合?我记得oracle有函数但是忘了.
我用select a.c,b.e from b,a where a.d=b.d and ff='123'
即将from里的a,b互换,将数据量小的a表作为driving table.
然后,如果ff='123'能够去掉大量的数据的话,将ff='123'放在
where后的最后一个,这点你没错.
create view as
select a.ff,a.c,b.e,b.d from a,b where a.d=b.d
create view as
select a.c as c,b.e as e from a,b where a.d=b.d and ff='123'
rule 模式下的规则:1、有两个索引存在的情况下,from后面大表在前。小表(返回记录少的表,不是记录少的表)在最后,作为驱动表,Oracle处理SQL语句是从左到右2、有一个索引,则顺序无关3、都没有索引,则大表应该在后