Vi è mai capitato che il server Confluence fosse a corto di spazio e non sapete chi carica di più gli allegati?
Per sapere questo è necessario avere accesso al database PostgreSQL di confluence.
Con una query SQL al database PostgreSQL è possibile ottenere statistiche utili su Confluence.
Dimensione totale di tutti gli allegati in Confluence:
SELECT s.spaceid,
s.spacename,
sum(LONGVAL)
FROM contentproperties c
JOIN content co ON c.contentid = co.contentid
JOIN spaces s ON co.spaceid = s.spaceid
WHERE c.contentid IN
(SELECT contentid
FROM content
WHERE contenttype = 'ATTACHMENT')
AND c.propertyname = 'FILESIZE'
GROUP BY s.spaceid
ORDER BY SUM DESC
LIMIT 5;Risultato (spacename sostituito):

Pagine con il maggior numero di versioni storiche nel tempo:
SELECT title,
MAX(VERSION)
FROM content
WHERE contenttype = 'PAGE'
GROUP BY title
ORDER BY 2 DESC
LIMIT 5;Risultato:

I file allegati più grandi nel vostro istanza di Confluence
SELECT DISTINCT c.contentid,
c.title AS attachmentTitle,
u.username AS uploadedBy,
co.title AS pageTitle,
cn.longval AS bytes
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
WHERE c.contenttype = 'ATTACHMENT'
AND cn.longval IS NOT NULL
ORDER BY cn.longval DESC
LIMIT 5;Risultato:

Numero di pagine nel cestino e dimensione totale delle pagine nel cestino per spazio:
SELEZIONA Count(content.contentid) AS number_of_trashed_pages,
Pg_size_pretty(SUM(Pg_column_size(bodycontent.BODY))) AS trash_total_size,
spaces.spacename AS space_name
DA bodycontent
INNER JOIN content ON (content.contentid = bodycontent.contentid)
INNER JOIN spaces ON (content.spaceid = spaces.spaceid)
DOVE bodycontent.contentid IN
(SELEZIONA contentid
DA content
DOVE content_status = 'deleted'
E contenttype = 'PAGE')
GROUP BY space_name
ORDER BY trash_total_size
LIMIT 5;Risultato:

Dimensione totale degli allegati caricati da ciascun utente su tutte le pagine
SELEZIONA u.lower_username,
sum(cp.longval) AS "size"
DA content c1
JOIN content c2 ON c1.contentid = c2.pageid
JOIN user_mapping u ON c1.creator=u.user_key
JOIN contentproperties cp ON c2.contentid = cp.contentid
DOVE c2.contenttype='ATTACHMENT'
GROUP BY u.lower_username
ORDER BY sum(cp.longval) DESC
LIMIT 5;Risultato:

P.S. Aggiungi al post query SQL utili per Confluence
Fonte: habr.com
