sql2008查询慢

twgxzjk 2010-09-01 11:44:08
下面这语句在sql2000上查询很快,在SQL2008上要6分钟,是啥原因啊

select top 1 c.iindex,table_caption,table_En,table_multi,d.table_name,d.presere
from chkuserlst b,chkflow a,FlowTab c,tabname d where b.kguid=a.kguid
and isnull(dealed,0)<>1
and a.FlowTable=c.Table_name and a.FlowTable=d.table_name
and not exists (select a0188 from CHKFLOWIDEA d
where d.kguid=a.kguid
and a0188='-1')
and ((b.A0188='-1')
or ((b.a0188 in (select e.kguid from userinfo e,a01holdrole f where e.kguid=f.roleid and f.a0188=-1))
))
order by c.iindex
...全文
97 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
「已注销」 2010-09-01
  • 打赏
  • 举报
回复
08退步了?
我觉得还是先Ctrl + L,看看执行计划,那边最耗时,可以对比一下2000与08的,应该都比较慢才是。
twgxzjk 2010-09-01
  • 打赏
  • 举报
回复
数据量很小的,每个表的记录都不超过4W,在SQL2000上几秒就够了,数据库附加到SQL2008后,刚开始还很快的,慢慢就越来越慢,跟踪了下,这条语句的执行都要6分钟
claro 2010-09-01
  • 打赏
  • 举报
回复
select top 1 c.iindex,table_caption,table_En,table_multi,d.table_name,d.presere
from chkuserlst b,chkflow a,FlowTab c,tabname d
where b.kguid=a.kguid
and isnull(dealed,0)<>1
and a.FlowTable=c.Table_name and a.FlowTable=d.table_name
and not exists (select a0188 from CHKFLOWIDEA d
where d.kguid=a.kguid
and a0188='-1')
and ((b.A0188='-1')
or ((b.a0188 in (select e.kguid from userinfo e,a01holdrole f where e.kguid=f.roleid and f.a0188=-1))
))
order by c.iindex


这在2000下能快到哪?10S
obuntu 2010-09-01
  • 打赏
  • 举报
回复
最好看下执行计划和执行统计信息,看问题出在哪里。
twgxzjk 2010-09-01
  • 打赏
  • 举报
回复
各表均有主键
chkflow——kguid
chkuserlst——kguid1
FlowTab——flowid
tabname——table_name

34,587

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧