How to Determine the Number of Attachments in My Confluence Instance
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs 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
How to Find the Number of Attachments in Confluence
DB level count:
To query the database for attachments, run this SQL:
Atlassian Support Offerings
The following SQL query is outside the scope of Atlassian Support Offerings and is provided for general guidance only.
1
2
3
4
5
6
7
-- To get the number of attachments in a space
select count(*) as "number of attachments", SPACES.SPACENAME from CONTENT
join SPACES on CONTENT.SPACEID = SPACES.SPACEID
where contenttype='ATTACHMENT' and spacename='<insert spacename here>'
and prevver is null
and content_status='current'
group by SPACES.SPACENAME
For Confluence 5.7 and above
1
2
3
4
5
-- To get a count of current attachment versions only
select count(*) from content where contenttype = 'ATTACHMENT' and prevver is null;
-- To get a count of all attachment versions
select count(*) from content where contenttype = 'ATTACHMENT';
For Confluence 5.6 and below
1
2
3
4
5
-- To get a count of current attachment versions only
select count(*) from attachments a join content c on a.pageid = c.contentid where c.prevver is null and a.prevver is null;
-- To get a count of all attachment versions
select count(*) from attachments;
File System count:
For linux
1
find pathtoattachments -type f | awk -F'/' '{print $(NF-1)}' | wc -l
Was this helpful?