How to Determine the Number of Attachments in My Confluence Instance

Still need help?

The Atlassian Community is here for you.

Ask the community

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.

-- 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
-- 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
-- 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
find pathtoattachments -type f | awk -F'/' '{print $(NF-1)}' | wc -l
Last modified on Jul 28, 2023

Was this helpful?

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