How do I determine the disk size of a SharePoint list?

别说谁变了你拦得住时间么 提交于 2019-12-01 19:28:17
ICodeForCoffee

If you enable a site quota, an option under site settings appears called Storage Space Allocation. When you go to set a quota in the Central Administration, the page will tell you what the current storage used is so you can have an idea before there. Once you get to the Storage Space Allocation report, you can see the total size of a library.

Unfortunately, you can't get this report without turning on a site quota.

Navigate to http://[myapplication]/[mySitecollection]/_layouts/storman.aspx

This will list the Storage Space Allocation for the site collection.

Robert Kaucher

I could not get Tim Dobrinski's suggestion to work. This T-SQL query does not deal with everything, but gives a very good idea. Pop it into Excel, then add a column for "Size in MB" and add in a formula.

USE [WSS_Content]
GO

SELECT
       [dbo].[Webs].[FullUrl]
      ,[dbo].[Lists].[tp_Title] AS "ListName"
      ,[dbo].[Docs].[DirName]
      ,[dbo].[Docs].[LeafName]
      ,[dbo].[Docs].[Size]
      ,[dbo].[Docs].[MetaInfoSize]
      ,[dbo].[Docs].[Version]
      ,[dbo].[Docs].[TimeCreated]
      ,[dbo].[Docs].[TimeLastModified]
      ,[dbo].[Docs].[MetaInfoTimeLastModified]
      ,[dbo].[Docs].[CheckoutUserId]
      ,[dbo].[Docs].[CheckoutDate]
      ,[dbo].[Docs].[ExtensionForFile]

  FROM [WSS_Content].[dbo].[Docs]
  INNER JOIN [WSS_Content].[dbo].[Webs] ON [dbo].[Webs].[Id] = [dbo].[Docs].[WebId]
  INNER JOIN [WSS_Content].[dbo].[Lists] ON [dbo].[Lists].[tp_ID] = [dbo].[Docs].[ListId]

  WHERE [dbo].[Docs].[Size] > 0     
  AND ([dbo].[Docs].[LeafName] NOT LIKE '%.stp')   
  AND ([dbo].[Docs].[LeafName] NOT LIKE '%.aspx')
  AND ([dbo].[Docs].[LeafName] NOT LIKE '%.xfp')
  AND ([dbo].[Docs].[LeafName] NOT LIKE '%.dwp')
  AND ([dbo].[Docs].[LeafName] NOT LIKE '%template%')
  AND ([dbo].[Docs].[LeafName] NOT LIKE '%.inf')
  AND ([dbo].[Docs].[LeafName] NOT LIKE '%.css')

If you save the list in question as a template to the file system, this should give you a rough idea of its size. If you need to do this on a periodic basis this approach is not as useful.

Site Settings -> Storage Metrics

You can see how much each object is consuming, click on Lists to see each individual list

You don't have to set a site quota

Sharepoint 2013

This is taken from SharePoint 2013:

USE [WSS_Content_Intranet]
GO

SELECT 
    (ISNULL(DocSizes,0) + ISNULL(UserDataSize,0)) As TotalSize, 
    nLists.tp_ID,
    nLists.tp_Title,
    nLists.tp_ItemCount,
    Webs.FullUrl
FROM
    Webs
INNER JOIN
    (
    SELECT 
        ALAux.ItemCount as tp_ItemCount, 
        Lists.tp_Title, 
        Lists.tp_ID, 
        Lists.tp_WebID, 
        ALAux.Modified as tp_Modified, 
        Lists.tp_ServerTemplate, 
        Docs.DirName, 
        Docs.LeafName, 
        Lists.tp_ImageUrl
    FROM 
        Lists
    CROSS APPLY
        TVF_AllListsAux_NoLock_ListId(Lists.tp_SiteId, Lists.tp_ID) AS ALAux
    INNER JOIN 
        Docs
    ON 
        Lists.tp_RootFolder = Docs.Id AND 
        Lists.tp_WebId = Docs.WebId 
    WHERE 
        tp_BaseType <> 1 AND
        Lists.tp_SiteId = YOUR_SITE_ID
    ) As nLists
    ON
        Webs.Id = nLists.tp_WebId
    LEFT OUTER JOIN
        (
        SELECT 
            (SUM(CAST((ISNULL(Docs.Size,0)) AS BIGINT))) As DocSizes, 
            Docs.ListId,
            Docs.SiteId
        FROM 
            Docs 
        WHERE
            Docs.Type = 0 AND SiteId = YOUR_SITE_ID
        GROUP BY
            Docs.ListId,Docs.SiteId
        ) As DocsInList
        ON
            DocsInList.ListId = nLists.tp_ID
        LEFT OUTER JOIN
            (
            SELECT 
                (SUM(CAST((ISNULL(tp_Size,0)) AS BIGINT))) As UserDataSize, 
                tp_ListId 
            FROM
                UserData 
            GROUP BY 
                UserData.tp_ListId
            ) AS UserDataInList
            ON
                UserDataInList.tp_ListId = DocsInList.ListId
ORDER BY TotalSize DESC

It returns all lists of all webs, summing the size of the items and the attached documents. Document libraries are not included, use this:

SELECT
    Lists.tp_Title,
    Lists.tp_ID as Id,
    SUM(Docs.Size/1024 + Docs.MetaInfoSize/1024)/1024 AS SizeMB,
    COUNT(*) as NumberOfFiles
FROM dbo.Docs
    INNER JOIN Webs ON Webs.Id = Docs.WebId
    INNER JOIN Lists ON Lists.tp_ID = Docs.ListId
WHERE Docs.Size > 0
GROUP BY Lists.tp_Title,Lists.tp_ID
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!