Mercurial > hg > orthanc
view OrthancServer/Database/InstallTrackAttachmentsSize.sql @ 3571:fa982a45062b
Merged in TomasZubiri/orthanc-1/Tomas-Zubiri/replaced-broken-url-with-url-from-waybac-1573762425576 (pull request #11)
Replaced broken url with url from wayback archive
author | Sébastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 15 Nov 2019 07:32:26 +0000 |
parents | 61da3c9b4121 |
children |
line wrap: on
line source
CREATE TABLE GlobalIntegers( key INTEGER PRIMARY KEY, value INTEGER); INSERT INTO GlobalProperties VALUES (6, 1); -- GlobalProperty_GetTotalSizeIsFast INSERT INTO GlobalIntegers SELECT 0, IFNULL(SUM(compressedSize), 0) FROM AttachedFiles; INSERT INTO GlobalIntegers SELECT 1, IFNULL(SUM(uncompressedSize), 0) FROM AttachedFiles; CREATE TRIGGER AttachedFileIncrementSize AFTER INSERT ON AttachedFiles BEGIN UPDATE GlobalIntegers SET value = value + new.compressedSize WHERE key = 0; UPDATE GlobalIntegers SET value = value + new.uncompressedSize WHERE key = 1; END; CREATE TRIGGER AttachedFileDecrementSize AFTER DELETE ON AttachedFiles BEGIN UPDATE GlobalIntegers SET value = value - old.compressedSize WHERE key = 0; UPDATE GlobalIntegers SET value = value - old.uncompressedSize WHERE key = 1; END;