Skip to content

Instantly share code, notes, and snippets.

@phette23
Created January 28, 2019 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phette23/0639653859e6d848102ed3b11eeacef6 to your computer and use it in GitHub Desktop.
Save phette23/0639653859e6d848102ed3b11eeacef6 to your computer and use it in GitHub Desktop.
how much disk space do the attachments for each openEQUELLA collection take up
-- attachment.value1 is the file size for "file" type attachments
-- does not capture a) zip files, b) generated thumbnails
-- but the item.total_file_size column which should include this is inaccurate
SELECT be.uuid, be_name.text AS collection, SUM(CAST(a.value1 AS bigint)) AS "disk space"
FROM item i
INNER JOIN base_entity be ON be.id = i.item_definition_id
LEFT JOIN language_string i_name ON i.name_id = i_name.bundle_id
LEFT JOIN language_string be_name ON be.name_id = be_name.bundle_id
JOIN (SELECT * FROM attachment WHERE attachment.type = 'file') a ON i.id = a.item_id
WHERE i.institution_id = 1165188
GROUP BY be.uuid, be_name.text
ORDER BY be_name.text ASC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment