How to Find the Total Amount of Space Used for a Single Space's Attachments
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
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