annotate OrthancServer/Database/InstallTrackAttachmentsSize.sql @ 4010:f0ee3f1db775

removed unused Logging::SetErrorWarnInfoTraceLoggingFunctions()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 08 Jun 2020 15:54:30 +0200
parents 61da3c9b4121
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3018
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 CREATE TABLE GlobalIntegers(
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 key INTEGER PRIMARY KEY,
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 value INTEGER);
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3018
diff changeset
5 INSERT INTO GlobalProperties VALUES (6, 1); -- GlobalProperty_GetTotalSizeIsFast
3018
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 INSERT INTO GlobalIntegers SELECT 0, IFNULL(SUM(compressedSize), 0) FROM AttachedFiles;
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 INSERT INTO GlobalIntegers SELECT 1, IFNULL(SUM(uncompressedSize), 0) FROM AttachedFiles;
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 CREATE TRIGGER AttachedFileIncrementSize
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 AFTER INSERT ON AttachedFiles
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 BEGIN
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 UPDATE GlobalIntegers SET value = value + new.compressedSize WHERE key = 0;
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 UPDATE GlobalIntegers SET value = value + new.uncompressedSize WHERE key = 1;
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 END;
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 CREATE TRIGGER AttachedFileDecrementSize
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 AFTER DELETE ON AttachedFiles
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 BEGIN
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 UPDATE GlobalIntegers SET value = value - old.compressedSize WHERE key = 0;
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 UPDATE GlobalIntegers SET value = value - old.uncompressedSize WHERE key = 1;
e3b5c07146a3 speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 END;