最近做关键字排名,当数据量到20万时候速度很慢,求高手帮忙优化,谢谢

evafly920 2005-08-05 11:00:43
最近做关键字排名,用下面的过程,当数据量到20万时候速度很慢,求高手帮忙优化,谢谢
Select * from A_Info as A
Inner Join B_Info As B On A.CorpID=B.CorpID

Where A.ParentID=0 and A.IsOpen=1 and A.IsAllow=1
and A.CorpID In (Select CorpID from B_Info where isAllow=1
and keyword=@Keyword and DateDiff(d,GetDate(),AddDate)<=ValidDay )

and A.AID In (Select Max(AID) from A_Info Group By CorpID)
Order By B.OrderRows Desc
效果如下
http://www.cn5135.com/Product/QueryResult.aspx?Keyword=%E6%89%8B%E6%9C%BA
...全文
160 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
张海霖 2005-08-06
  • 打赏
  • 举报
回复
能不order by就别order by
zjcxc 2005-08-05
  • 打赏
  • 举报
回复
1. 试试上面的方式
2. 去掉order by ,看看是否order by 导致
zjcxc 2005-08-05
  • 打赏
  • 举报
回复
Select * from A_Info as A
Inner Join B_Info As B On A.CorpID=B.CorpID
Inner Join (
Select DISTINCT CorpID from B_Info
where isAllow=1
and keyword=@Keyword
and DateDiff(d,GetDate(),AddDate)<=ValidDay
)C ON A.CorpID=C.CorpID
Inner Join (
Select AID=Max(AID) from A_Info Group By CorpID
)D ON A.AID=D.AID
Where A.ParentID=0 and A.IsOpen=1 and A.IsAllow=1
Order By B.OrderRows Desc
bugchen888 2005-08-05
  • 打赏
  • 举报
回复
create index idx_B_Info_001 on B_Info(keyword,AddDate,ValidDay,CorpID)
create index idx_A_Info_001 on A_Info(CorpID,AID)
evafly920 2005-08-05
  • 打赏
  • 举报
回复
谢谢老大,我试下看

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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