Skip to main content

How can I view the largest binary files within my database?

The following queries list files from your database from largest to smallest. They're useful when the database has grown unexpectedly and you need to find what's taking the space.

SQL Server

SQL
SELECT s.name as site_name, f.cachePath, b.id, datalength(data)
FROM cxml_blob b
join cxml_foldercontent f on b.id=f.fileBlobId
join cxml_site s on s.id = f.siteid
order by datalength(data) DESC;

Oracle

SQL
SELECT f.cachePath, b.id, dbms_lob.getLength(data)
FROM dbNameHere.cxml_blob b
join dbNameHere.cxml_foldercontent f on b.id=f.fileBlobId
order by dbms_lob.getLength(data) DESC nulls last;

Replace dbNameHere with your actual database name.

MySQL

SQL
SELECT s.name as site_name, f.cachePath, b.id, OCTET_LENGTH(data)
FROM cxml_blob b
join cxml_foldercontent f on b.id=f.fileBlobId
join cxml_site s on s.id = f.siteid
order by OCTET_LENGTH(data) DESC;

For what to do with the results, see Database Size Management Tips.