我们使用服务代理两个多月,突然发现系统的整体性能下降了。经过大量挖掘和分析指标,我发现我page life expectancy的很低。然后我在 simplesqlserver 的帮助下查看了我的缓冲池,它填充了 sys.sysdercv 对象(5 GB)。在搜索了更多之后,我发现sys.conversation_endpoint有 1900 万行和10 GB 数据。我的错误是没有结束目标队列中的对话,但是在双方(发起者和目标队列)结束对话后,它仍然保持在sys.conversation_endpointsCD 状态(已关闭)。删除此行的一种方法是调用end conversation with cleanup但是需要很长时间才能完成。我写了这份工作,但我想它需要超过 7 天才能完成。这是我的工作:
DECLARE @BatchSize Int
SELECT @BatchSize = 1000
declare @i int = @BatchSize;
declare @sum int = 0;
WHILE @i = @BatchSize BEGIN
print concat('while ', @sum);
select @i = 0;
declare @handle uniqueidentifier
declare conv cursor for select top (@BatchSize) conversation_handle from sys.conversation_endpoints
open conv
fetch NEXT FROM conv into @handle
while @@FETCH_STATUS = 0
Begin
select @i = @i + 1;
END Conversation @handle with cleanup
fetch NEXT FROM conv into @handle
End
close conv
deallocate conv
select @sum = @sum + @i;
END
所以,这是我的问题:我怎样才能一次截断这个表及其数据。就像 truncate command 一样truncate table sys.conversation_endpoints,这个命令会产生这个错误:
Cannot find the object "conversation_endpoints" because it does not exist or you do not have permissions.
我想知道,是否有任何服务可以重新启动它或做任何安全删除大量数据的事情?