How to Find the Total Amount of Space Used for a Single Space's Attachments

Still need help?

The Atlassian Community is here for you.

Ask the community

Purpose

As an admin, you may want to find how much space is being used by attachments for a given Space. On this page, we'll explain a database query that can be run to find the total size of attachments, in bytes, per Space.

Solution

The queries below have been tested in MySQL, so they may need to be adapted for other database types.


Confluence 5.8.x and higher

select 
    s.spacekey, 
    sum(LONGVAL) 
FROM 
    contentproperties cp
JOIN content c
ON 
    cp.contentid = c.contentid
JOIN spaces s
ON 
    s.spaceid = c.spaceid 
WHERE 
    c.contenttype = 'ATTACHMENT' 
AND 
    cp.propertyname = 'FILESIZE' 
GROUP BY 
    s.spacekey
; 


Confluence 5.7.x and lower

SELECT
    s.spacekey,
    SUM(filesize)
FROM
    attachments a
JOIN content c
ON
    a.pageid = c.contentid
JOIN spaces s
ON
    c.spaceid = s.spaceid
GROUP BY
    s.spacekey



Last modified on May 5, 2017

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.