Track down big attachments

Hi,

I'm faced with a rather large attachments directory (2Gb), and I'm looking for a way to display a list of attachments with their size, space, and location.

3 answers

1 accepted

Hey Dick,

You can do that by running this query in the Confluence Database:

SELECT a.TITLE AS "Attachment Name", a.FILESIZE, c.TITLE AS "Page Title", s.SPACENAME AS "Space Name", CONCAT("http://<YourConfluenceURL>/pages/viewpageattachments.action?pageId=", a.PAGEID) AS "Location" FROM attachments a JOIN content c ON a.PAGEID = c.CONTENTID JOIN spaces s ON c.SPACEID = s.SPACEID ORDER BY a.FILESIZE DESC;

Replace <yourConfluenceURL> with your Confluence URL. That will give you the correct hyperlink to each attachments' location. Added this as a KB here: https://confluence.atlassian.com/pages/viewpage.action?pageId=346325893

This was tested with MySQL (some DB might not have a CONCAT function. Check the DB manual for the correct method to concatenate 2 strings).

Foogie

Thanks, this is what I was looking for.

I adjusted it a bit becuase we run PG, so it was possible to do this straight from the command line, did some formatting stuff, and sorted by Space name (so I can blame specific space admins):

postgres@confluence:~$ psql confluencedb -Atc "SELECT s.SPACENAME, pg_size_pretty(a.FILESIZE), a.TITLE AS AttachmentName, c.TITLE AS PageTitle, s.SPACENAME AS SpaceName, 'https://confluence.terena.org/pages/viewpageattachments.action?pageId=' || a.PAGEID AS Location FROM attachments a JOIN content c ON a.PAGEID = c.CONTENTID JOIN spaces s ON c.SPACEID = s.SPACEID WHERE a.FILESIZE &gt; 1048576 ORDER BY s.SPACENAME, a.FILESIZE DESC"

Here is the same query for SQL Server

SELECT a.TITLE AS "Attachment Name", a.FILESIZE, c.TITLE AS "Page Title", s.SPACENAME AS "Space Name", 'http://&lt;yourConfluenceURL&gt;/pages/viewpageattachments.action?pageId='+convert(varchar(10),a.PAGEID) AS "Location" FROM [ConfluenceDB].[dbo].[ATTACHMENTS] a JOIN [ConfluenceDB].[dbo].[CONTENT] c ON a.PAGEID = c.CONTENTID JOIN [ConfluenceDB].[dbo].[SPACES] s ON c.SPACEID = s.SPACEID ORDER BY a.FILESIZE DESC;

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

762 views 23 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you