Blog post

Custom scripts for Confluence health-check: find out how effective your tool is

Home    —    Blog    —    Custom scripts for Confluence health-check: find out how effective your tool is
Aleks Yenin
Posted by Aleks Yenin
July 24, 2020

In terms of periodical Confluence performance audit, we also check how effective the tool and licensing are. 

How to boost the speed of Confluence and processes in it without additional investing in servers? The first thing you need to do is to evaluate the current performance. We’re glad to share the scripts to check various criteria that help to make decisions about the system optimization. 

The scripts work with the PostgreSQL, as it’s the most popular database for Confluence. They can be easily adapted to other databases like Oracle, MySQL, MS SQL. Let us know if you need some help. 

7 ready-to-go scripts for Confluence:

25 biggest attachments 

We search for the biggest attachments and analyze what they are, and if there’s a reason to keep them.

SELECT DISTINCT c.title AS attachmentTitle, u.username AS uploadedBy, s.spacekey, co.title AS pageTitle, cn.longval/1024/1024 as mbytes
FROM CONTENT AS c
JOIN USER_MAPPING AS u
ON u.user_key = c.creator
JOIN CONTENT AS co
ON c.pageid = co.contentid
JOIN CONTENTPROPERTIES AS cn
ON cn.contentid = c.contentid
JOIN SPACES AS s
ON c.spaceid = s.spaceid
WHERE c.contenttype = 'ATTACHMENT'
AND cn.longval IS NOT NULL
ORDER BY mbytes DESC LIMIT 25;

Inactive users

We check inactive users to delete them if needed.

SELECT cu.user_name, cu.first_name, cu.last_name, cu.created_date, cu.updated_date, cd.directory_name
FROM cwd_user cu
JOIN cwd_directory cd ON cu.directory_id = cd.id
WHERE cu.active = 'F';

Users with old last login data

We check the users who didn’t log-in in Confluence lately, and decide whether you need to spend licenses on them. 

SELECT cu.user_name, cu.first_name, cu.last_name, cu.email_address,
       li.successdate, li.PREVsuccessdate
FROM logininfo li
JOIN user_mapping um ON um.user_key = li.username
JOIN cwd_user cu ON um.username = cu.user_name
JOIN cwd_directory cd ON cu.directory_id = cd.id
where li.successdate < '2019-10-01'
ORDER BY successdate;

Spaces with large volume of attachments

We search for spaces with the largest volume of attachments, analyze and optimize them.

select
    s.spacekey,
    sum(LONGVAL/1024/1024)
FROM
    contentproperties cp
JOIN content c
ON
    cp.contentid = c.contentid
JOIN spaces s
ON
    s.spaceid = c.spaceid
WHERE
    c.contenttype = 'ATTACHMENT'
AND
    cp.propertyname = 'FILESIZE'
GROUP BY
    s.spacekey
oRDER BY sum(LONGVAL) desc
;

Largest pages

Analyzing the largest pages and optimizing them.

SELECT s.spacekey, c.title, LENGTH(bc.body)
FROM BODYCONTENT bc
JOIN CONTENT c ON bc.contentid = c.contentid
JOIN SPACES s ON c.spaceid = s.spaceid
WHERE c.prevver IS NULL AND c.contenttype IN ('BLOGPOST','PAGE')
ORDER BY LENGTH(bc.body) DESC LIMIT 25;

Pages with the biggest sum of version sizes

Searching for pages with the biggest sum of version sizes. Sometimes there can be dozens and hundreds of thousands versions. Let’s get rid of unnecessary ones.

SELECT s.spacekey, c.title, subq.sum_size_in_bytes / 1024/1024
FROM CONTENT c
JOIN SPACES s ON c.spaceid = s.spaceid
JOIN (
    SELECT c2.prevver, SUM(LENGTH(bc.body)) AS sum_size_in_bytes
    FROM BODYCONTENT bc
    JOIN CONTENT c2 ON bc.contentid = c2.contentid
    WHERE c2.prevver IS NOT NULL AND c2.contenttype IN ('BLOGPOST','PAGE')
    GROUP BY c2.prevver
    ORDER BY SUM(LENGTH(bc.body)) DESC LIMIT 25
) AS subq ON c.contentid = subq.prevver
ORDER BY subq.sum_size_in_bytes DESC;

All about calendars

Calendars in Confluence have complex and resource-consuming structure. We analyze what’s going on with them. Sometimes there can be hundreds of forgotten calendars. Let’s get rid of them.

SELECT um.lower_username as creator, tc."NAME" as calendar_name, to_timestamp(CAST(tc."CREATED" AS bigint)/1000) as creation_date
FROM "AO_950DC3_TC_SUBCALS" tc
JOIN user_mapping um ON um.user_key = tc."CREATOR"
WHERE tc."PARENT_ID" IS NULL
ORDER BY creator;

It’s just the tip of the iceberg, a small part of our expertise to get better performance, reliability and fail free Confluence.

Didn’t manage to find a solution? Feel free to schedule a free 30-min consultation, and discuss your project. 

Other services by Polontech

Services

Atlassian migration

To Server. To Cloud. To Data Center. Server to Server. Cloud to Cloud. To Atlassian.
go to page
Services

Atlassian configuration

Jira Software. Confluence. Jira Service Desk. Atlassian addons. Custom scripting.
go to page
Services

Training

Fast start. Agile. ITSM. Atlassian.
go to page
Services

Support

Technical support 24/7. Health check. Upgrade. Data protection. Managed Services.
go to page
Services

Installation

Choosing Atlassian products. Atlassian product at your service. Installing Atlassian in the cloud or server...
go to page
Services

Consulting

Audit. Jira Add-ons. Agile. ITIL/ITSM. User management. Team collaboration. Asset management...
go to page
Services

Hosting

Migration to Atlassian Cloud. Private cloud. Public cloud.
go to page
Services

Portfolio management

Audit. Design. Launch. Support.
go to page
Services

Licensing

Buying. Renewal. Managed licenses.
go to page
Services

CI/CD + DevOps

DevOps strategy. Commit. Build. Test. Deploy.
go to page

Use form to contact us