From 20988a70cc651d411de9645fe85615cbd5ad21aa Mon Sep 17 00:00:00 2001 From: Graham Date: Sun, 21 Feb 2021 17:49:20 +0000 Subject: [PATCH] Add size column to the master_index_group_stats view Signed-off-by: Graham --- .../resources/org/openrs2/archive/migrations/V1__init.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/archive/src/main/resources/org/openrs2/archive/migrations/V1__init.sql b/archive/src/main/resources/org/openrs2/archive/migrations/V1__init.sql index 606e5c11da..ec9808c5bd 100644 --- a/archive/src/main/resources/org/openrs2/archive/migrations/V1__init.sql +++ b/archive/src/main/resources/org/openrs2/archive/migrations/V1__init.sql @@ -172,13 +172,14 @@ GROUP BY a.master_index_id; CREATE UNIQUE INDEX ON master_index_archive_stats (master_index_id); -CREATE MATERIALIZED VIEW master_index_group_stats (master_index_id, groups, valid_groups, keys, valid_keys) AS +CREATE MATERIALIZED VIEW master_index_group_stats (master_index_id, groups, valid_groups, keys, valid_keys, size) AS SELECT i.master_index_id, COUNT(*), COUNT(g.container_id), COUNT(*) FILTER (WHERE c.encrypted), - COUNT(*) FILTER (WHERE c.key_id IS NOT NULL) + COUNT(*) FILTER (WHERE c.key_id IS NOT NULL), + SUM(length(c.data)) FROM resolved_indexes i JOIN index_groups ig ON ig.container_id = i.container_id LEFT JOIN groups g ON g.archive_id = i.archive_id AND g.group_id = ig.group_id AND (