使用删除存储过程减少 TFS 数据库大小是否安全? [英] Is it safe to reduce TFS DB size by using Delete stored procedures?

查看:21
本文介绍了使用删除存储过程减少 TFS 数据库大小是否安全?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有 TFS 2017.3 及其庞大的数据库 - 大约 1.6 TB.

We have TFS 2017.3 and the database it's huge - about 1.6 TB.

我想尝试通过运行这两个存储过程来清理空间:

I want to try to clean up the space by running these 2 stored procedures:

  • prc_CleanupDeletedFileContent
  • prc_DeleteUnusedFiles
  • prc_DeleteUnusedContent

运行它安全吗?它是否有可能删除我当前正在使用的重要内容?(当然,我之前会做一个备份...)

Is it safe to run it? Is there a chance that it will delete important things I am currently using? (of course, I will do a backup before...)

放入这些存储过程的最佳值是什么?

What are the best values to put in these stored procedures?

另一件事 - 如果我运行这个查询:

Another thing - If I run this query:

SELECT A.[ResourceId]  
FROM [Tfs_DefaultCollection].[dbo].[tbl_Content] As A
left join [Tfs_DefaultCollection].[dbo].[tbl_FileMetadata] As B on A.ResourceId=B.ResourceId
where B.[ResourceId] IS Null

我得到了 10681 的结果.如果我运行此查询:

I got result of 10681. If I run this query:

SELECT A.[ResourceId]  
FROM PTU_NICE_Coll.[dbo].[tbl_Content] As A
left join PTU_NICE_Coll.[dbo].tbl_FileReference As B on A.ResourceId=B.ResourceId
where B.[ResourceId] IS Null

我得到了 10896 的结果.

I got result of 10896.

如何删除这些行?删除它们是否完全安全?

How can I remove this rows? and is it completely safe to remove them?

推荐答案

一般我们不建议直接对 DB 进行操作,因为这可能会导致问题.

Generally we don't recommend to do actions against the DB directly as it may cause problems.

但是,如果您必须这样做,那么您需要先备份数据库.

However if you have to do that, then you need to backup the DBs first.

您可以参考以下文章来清理和减少 TFS 数据库的大小:

You can refer to below articles to clean up and reduce the size of the TFS databases:

另一种选择是深入数据库,并运行清理手动存储过程.如果您的内容表很大:

Another option is to dive deep into the database, and run the cleanup stored procedures manually. If your Content table is large:

EXEC prc_DeleteUnusedContent 1

如果您的文件表很大:

EXEC prc_DeleteUnusedFiles 1, 0, 1000

这第二个 sproc 可能会运行很长时间,这就是为什么它有第三个定义批量大小的参数.你应该运行这个 sprocs多次,或者如果它很快完成,你可以增加块尺寸.

This second sproc may run for a long time, that’s why it has the third parameter which defines the batch size. You should run this sprocs multiple times, or if it completes quickly, you can increase the chunk size.

这篇关于使用删除存储过程减少 TFS 数据库大小是否安全?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆