我在SYBASE库中执行如下SQL,很久没有反应
A表32万记录,B表2万记录
其中col2是A表的主键 ;col5是B表的索引;col5在表中的重复率非常低 ,
执行如下SQL
select A.col2
from A,B
where B.col1='B'
and B.col2='B'
and B.col3='C'
and B.col4='dfdfdf'
and A.col2=B.col5
但20分钟后还没出来
写一个过程
create procedure t
as
select distinct col5 as col5 into #t from B
where B.col1='B' and B.col2='B'and B.col3='C' and B.col4='dfdfdf'
select A.col2 from A,#t where A.col2=#t.col5
;
效率肯定不错