難題:同樣的查詢,配制低的服務器反而速度快,怎麼辦?

dreamyyuan 2006-04-04 03:16:42
1、Win2000+SQL2000(4CPU+2G內存 20萬HP服務器)
select part_no into #temp From dbo.sh_outin_histoy where date>'2006-04-03' and date<'2006-04-04' and d_class='調撥'
select * from sh_outin_histoy where part_no in (select part_no from #temp)
and d_class in ('領用','補料') and date>'2006-04-03' and date<'2006-04-04'
時間是:0秒

select * from sh_outin_histoy a where part_no in (select part_no From dbo.sh_outin_histoy b where date>'2006-04-03' and date<'2006-04-04' and d_class='調撥' )
and d_class in ('領用','補料') and date>'2006-04-03' and date<'2006-04-04'
時間是:3分53秒

2、NT+SQL2000(2CPU+1G內存 5萬HP服務器)
select part_no into #temp From dbo.sh_outin_histoy where date>'2006-04-03' and date<'2006-04-04' and d_class='調撥'

select * from sh_outin_histoy where part_no in (select part_no from #temp)
and d_class in ('領用','補料') and date>'2006-04-03' and date<'2006-04-04'
時間是:0秒
select * from sh_outin_histoy a where part_no in (select part_no From dbo.sh_outin_histoy b where date>'2006-04-03' and date<'2006-04-04' and d_class='調撥' )
and d_class in ('領用','補料') and date>'2006-04-03' and date<'2006-04-04'
時間是:0秒

為什麼查詢有這麼大的差別呢?
查了幾次都這樣。

...全文
174 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
尚和空四 2006-04-05
  • 打赏
  • 举报
回复
和系统的优化等等也有关系的
并且你去签订它们的快慢标准也不好定
小数据量是显示不出的。
dreamyyuan 2006-04-05
  • 打赏
  • 举报
回复
大不了把系統改成NT再測測。
dreamyyuan 2006-04-05
  • 打赏
  • 举报
回复
人氣這麼低呀,:(
Snoworld 2006-04-05
  • 打赏
  • 举报
回复
建立索引,
优化收缩数据库,
清空日志。
dreamyyuan 2006-04-05
  • 打赏
  • 举报
回复
建了個part_no索引就快了很多。
jwt1982 2006-04-04
  • 打赏
  • 举报
回复
备份后再导入的文件,数据就是整理过的(相对原来,物理位置能好些)

DTS的也一样。
dreamyyuan 2006-04-04
  • 打赏
  • 举报
回复
是备份后恢复的,怎樣速整理文件碎片?
jwt1982 2006-04-04
  • 打赏
  • 举报
回复
另外看看你那个好机器的数据文件大小,是不是另一个是备份后恢复的?

可能产生太多的文件碎片也是有可能的。
jwt1982 2006-04-04
  • 打赏
  • 举报
回复
不一定就是CPU数目、内存高就好的。

我目前手里有个服务器IBM 3个至强CPU 4G内存,跑一个查询就没有一个PC服务器快,才P4-2.4-512M内存的机器。

34,587

社区成员

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

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