[Quote=引用 17 楼 ruanwxh 的回复:]
刚才没事的时候,我测了下
发现好像是in和exists好像一样的
我创建了test和stu两张表 (id,time)索引都建在id
test60w个数据,stu600个数据
用pl/sql测试
1.
select * from test where id in (select id from stu)
select * from test t where exists (select 1 from stu s where s.id = t.id)
****************************************************************
2.
select * from stu where id in (select id from test)
select * from stu s where exists (select 1 from test t where t.id =s.id)
按F5测试:
第1种情况cost 447
第2种情况cost 555
刚才没事的时候,我测了下
发现好像是in和exists好像一样的
我创建了test和stu两张表 (id,time)索引都建在id
test60w个数据,stu600个数据
用pl/sql测试
1.
select * from test where id in (select id from stu)
select * from test t where exists (select 1 from stu s where s.id = t.id)
****************************************************************
2.
select * from stu where id in (select id from test)
select * from stu s where exists (select 1 from test t where t.id =s.id)
按F5测试:
第1种情况cost 447
第2种情况cost 555