ALTER function GetInvitePersonCount(@ActorCode varchar(10))
returns int
as
begin
declare @PersonCount int
select @PersonCount=count(*) from InvitePerson p
where exists(select t.InviteID from InviteInfo t where t.InviteID=p.InviteID and
exists( select j.ActorCode from ActorJoin j where j.ActorCode=t.ActorCode
and ([email protected] or [email protected])))
return @PersonCount
end
当这三个表数据量很大的时候执行数据就比较慢了,希望高手们看能不能优化一下!谢谢各位了
------解决方案--------------------
ALTER function GetInvitePersonCount(@ActorCode varchar(10))
returns int
as
begin
declare @PersonCount int
select @PersonCount=count(1) from InvitePerson p
inner join InviteInfo t on t.InviteID=p.InviteID
inner join ActorJoin j on j.ActorCode=t.ActorCode
where [email protected] or [email protected]
return @PersonCount
end