Created
January 28, 2019 23:25
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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