22,209
社区成员
发帖
与我相关
我的任务
分享
and
(
1=1
or deptid in (select deptid from dbo.pub_getRoleUserAndDeptid('6,7') where st_id = 1)
or createDeptid in (select deptid from dbo.pub_getRoleUserAndDeptid('6,7') where st_id = 1)
)
creator=1
or
(
deptid in (select deptid from dbo.pub_getRoleUserAndDeptid('6,7') where st_id = 1)
or
createDeptid in (select deptid from dbo.pub_getRoleUserAndDeptid('6,7') where st_id = 1)
)
把1=1换成表中字段creator=1的时候or与and效率也相差很大
语句单独执行都很快加起来都没1秒,放一起就很慢了将近30秒and
(
1=1
or exists(select 1 from dbo.pub_getRoleUserAndDeptid('6,7') as b
where st_id = 1 and (a.deptid=b.deptid or a.createDeptid=b.deptid)
)
and
(
1=1
and( deptid in (select deptid from dbo.pub_getRoleUserAndDeptid('6,7') where st_id = 1)
or createDeptid in (select deptid from dbo.pub_getRoleUserAndDeptid('6,7') where st_id = 1))
)
我想知道你改为这样执行,效果如何。