How to query the database to find the size of spaces in Confluence Data Center

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

Summary

This document will help identify all space sizes (excluding the attachments) from the underlying database.

Solution

The below SQL will help us to know the size of spaces.

Oracle

1 2 3 4 5 6 7 8 9 10 11 12 13 14 SELECT Count(CONTENT.CONTENTID) AS number_of_pages, nvl((sum(dbms_lob.getlength(bodycontent.BODY))),0) AS total_size_bytes, 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 <> 'deleted' AND (contenttype = 'PAGE' OR contenttype = 'BLOGPOST')) GROUP BY SPACES.spacename;

Postgres

1 2 3 4 5 6 7 8 9 10 11 12 13 14 SELECT Count(CONTENT.CONTENTID) AS number_of_pages, sum(LENGTH(bodycontent.BODY)) AS total_size_bytes, 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 <> 'deleted' AND (contenttype = 'PAGE' OR contenttype = 'BLOGPOST')) GROUP BY SPACES.spacename;

MySQL

1 2 3 4 5 6 7 8 9 10 11 12 13 14 SELECT COUNT(CONTENT.CONTENTID) AS NUMBER_OF_PAGES, SUM(LENGTH(BODYCONTENT.BODY)) AS TOTAL_SIZE_BYTES, 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 <> 'deleted' AND (CONTENTTYPE = 'PAGE' OR CONTENTTYPE = 'BLOGPOST')) GROUP BY SPACES.SPACENAME;

Updated on March 13, 2025

Still need help?

The Atlassian Community is here for you.