How to query the database to find the size of all page drafts per space

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Server and Data Center Only - This article only applies to Atlassian products on the server and data center platforms.

 

Summary

Confluence administrators may want to audit draft page usage on their instance. 

Solution

The following query will identify the number of pages with a status of "draft" and the total size they take up in the database, per space:

select
    count(content.contentid) as number_of_drafts,
    pg_size_pretty(sum(pg_column_size(bodycontent.body))) as total_size_of_drafts,
	spaces.spacename as space_name
from bodycontent 
inner join content on (content.contentid = bodycontent.contentid)
inner join spaces on (content.spaceid = spaces.spaceid)
where bodycontent.contentid in 
(select contentid from CONTENT where CONTENT_STATUS = 'draft' and CONTENTTYPE = 'PAGE') 
GROUP BY space_name
ORDER BY number_of_drafts DESC, space_name;

The query above is written for PostgresSQL databases and may require adjustment for other platforms.

Last modified on Apr 11, 2020

Was this helpful?

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