【发布时间】:2010-10-29 15:47:14
【问题描述】:
在我的 MS SQL Server 2008 上,我创建了一个像这样的临时表:
create table #test
(
A varchar(50),
B int,
)
insert into #test select 'a',45
insert into #test select 'b',587
insert into #test select 'a',4
insert into #test select 'b',58
现在下面的请求需要永远
select A,SUM(B) from #test group by A -- takes 4 seconds to execute
虽然以下请求是即时的
select * from #test order by A
select SUM(B) from #test
所有其他不使用临时表的请求(包括大请求)都运行良好,而使用临时表的每个请求似乎都遇到了相同的性能问题。昨天这些请求通常都运行得很快,我想不出从那以后会发生什么不寻常的事情。
我使用已用空间检查了我的 tempdb 未满(85 MB 中有 70 MB 可用)
我也检索到了执行计划:
什么可能导致这种非常糟糕的性能?有什么我应该解决的问题吗?
【问题讨论】:
标签: sql performance sql-server-2008