How to find duplicate attachments for my Confluence instance?


Could you please suggest how could I find all the duplicate attachments within my Confluence instance?

any specific SQL query to search it in database, as my query results includes versions also.

Thanks and Regards,

Jenin C M

2 answers

1 accepted

To exclude versions - get the latest version only, you should append prevver IS NULL in your WHERE statement.

If you could provide your SQL query, that would be easier for us to help tweaking it. :)

Hi Husein,

Thanks for your response!!

The query I am trying to fetch the duplicate attachments is:

select distinct title, pageid from attachments where attachmentid in (select distinct(a.attachmentid) from attachments a inner join attachments b on a.title = b.title and a.filesize=b.filesize and a.pageid=b.pageid where a.attachmentid <> b.attachmentid);

This query is generating a very large list of attachments (it includes all the versions) but I need only duplicated attachments i.e same pageid, filesize, content but different attachmentid.

Your response will be much appreciated.




You just want to add "count(*) as Kount", group by title, filesize, and "having kount > 0"

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Friday in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

274 views 11 10
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