找出占用空间的TFS中的哪个项目

时间:2017-10-30 10:11:36

标签: tfs tfs2017

我们需要弄清楚哪些项目使我们的TFS数据库失控,我们found this script,但它不适用于最新版本的TFS。

有没有人有更新的脚本?

1 个答案:

答案 0 :(得分:2)

首先,您可以运行SQL脚本以显示过去几个月tbl_Content的增加:

SELECT DATEPART(yyyy, CreationDate) AS [year]
    ,DATEPART(mm, CreationDate) AS [month]
    ,COUNT(*) AS [count]
    ,SUM(DATALENGTH(Content)) / 1048576.0 AS [Size in Mb]
    ,(SUM(DATALENGTH(Content)) / 1048576.0) / count(*) AS [Average Size]
FROM tbl_Content
GROUP BY DATEPART(yyyy, CreationDate)
    ,DATEPART(mm, CreationDate)
ORDER BY DATEPART(yyyy, CreationDate)
    ,DATEPART(mm, CreationDate)

这将反映您的收集数据库是否有异常增加。然后你可以看看"所有者"的分布情况。对于tbl_Content中的数据,例如VersionControl,Work Item,Test ...哪个区域的百分比最大。

详细SQL脚本:

SELECT Owner = CASE
    WHEN OwnerId = 0 THEN 'Generic'
    WHEN OwnerId = 1 THEN 'VersionControl'
    WHEN OwnerId = 2 THEN 'WorkItemTracking'
    WHEN OwnerId = 3 THEN 'TeamBuild'
    WHEN OwnerId = 4 THEN 'TeamTest'
    WHEN OwnerId = 5 THEN 'Servicing'
    WHEN OwnerId = 6 THEN 'UnitTest'
    WHEN OwnerId = 7 THEN 'WebAccess'
    WHEN OwnerId = 8 THEN 'ProcessTemplate'
    WHEN OwnerId = 9 THEN 'StrongBox'
    WHEN OwnerId = 10 THEN 'FileContainer'
    WHEN OwnerId = 11 THEN 'CodeSense'
    WHEN OwnerId = 12 THEN 'Profile'
    WHEN OwnerId = 13 THEN 'Aad'
    WHEN OwnerId = 14 THEN 'Gallery'
    WHEN OwnerId = 15 THEN 'BlobStore'
    WHEN OwnerId = 255 THEN 'PendingDeletion'
    END,
    SUM(CompressedLength) / 1024.0 / 1024.0 AS BlobSizeInMB
FROM tbl_FileReference AS r
JOIN tbl_FileMetadata AS m ON r.ResourceId = m.ResourceId
    AND r.PartitionId = m.PartitionId
WHERE r.PartitionId = 1
GROUP BY OwnerId
ORDER BY 2 DESC

(有关详细信息,请参阅评论中提供的link @jessehouwing。)

要减小tbl_Content表的大小,您可以参考此博客:TFS tbl_Content Table and Database growth out of control

  1. 清理一些您不再需要的旧工作区。
  2. 运行tf destory command以永久删除这些不必要的源文件。
  3. 使用TFS电源工具clean Test attachments并测试结果。