From 30bb2a4100c46a162e739ea85789ddb9f83da66c Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Fri, 31 Oct 2025 17:19:44 -0700 Subject: [PATCH 1/3] Admin Console report to show table sizes; metrics for schema sizes --- core/src/org/labkey/core/CoreModule.java | 12 ++++++ .../labkey/core/admin/AdminController.java | 10 +++++ .../core/query/PostgresTableSizesTable.java | 39 +++++++++++++++++++ .../labkey/core/query/PostgresUserSchema.java | 3 ++ 4 files changed, 64 insertions(+) create mode 100644 core/src/org/labkey/core/query/PostgresTableSizesTable.java diff --git a/core/src/org/labkey/core/CoreModule.java b/core/src/org/labkey/core/CoreModule.java index e35275d1395..23391a9f3cb 100644 --- a/core/src/org/labkey/core/CoreModule.java +++ b/core/src/org/labkey/core/CoreModule.java @@ -269,6 +269,7 @@ import org.labkey.core.qc.DataStateWriter; import org.labkey.core.query.AttachmentAuditProvider; import org.labkey.core.query.CoreQuerySchema; +import org.labkey.core.query.PostgresTableSizesTable; import org.labkey.core.query.PostgresUserSchema; import org.labkey.core.query.UserAuditProvider; import org.labkey.core.query.UsersDomainKind; @@ -1231,6 +1232,17 @@ public void moduleStartupComplete(ServletContext servletContext) results.put("workbookCount", ContainerManager.getWorkbookCount()); results.put("archivedFolderCount", ContainerManager.getArchivedContainerCount()); results.put("databaseSize", CoreSchema.getInstance().getSchema().getScope().getDatabaseSize()); + + if (CoreSchema.getInstance().getSqlDialect().isPostgreSQL()) + { + SQLFragment sql = new SQLFragment("SELECT table_schema, SUM(total_size) FROM "); + sql.append(new PostgresTableSizesTable(new PostgresUserSchema(User.getAdminServiceUser(), ContainerManager.getRoot())), "t"); + sql.append(" GROUP BY table_schema"); + + var schemaSizes = new SqlSelector(CoreSchema.getInstance().getSchema(), sql).getValueMap(); + results.put("databaseSchemaSize", schemaSizes); + } + results.put("scriptEngines", LabKeyScriptEngineManager.get().getScriptEngineMetrics()); results.put("customLabels", CustomLabelService.get().getCustomLabelMetrics()); Map roleAssignments = new HashMap<>(); diff --git a/core/src/org/labkey/core/admin/AdminController.java b/core/src/org/labkey/core/admin/AdminController.java index a24b9b65076..77400aacfe0 100644 --- a/core/src/org/labkey/core/admin/AdminController.java +++ b/core/src/org/labkey/core/admin/AdminController.java @@ -486,6 +486,7 @@ public static void registerAdminConsoleLinks() { AdminConsole.addLink(Diagnostics, "postgres activity", new ActionURL(PostgresStatActivityAction.class, root)); AdminConsole.addLink(Diagnostics, "postgres locks", new ActionURL(PostgresLocksAction.class, root)); + AdminConsole.addLink(Diagnostics, "postgres table sizes", new ActionURL(PostgresTableSizesAction.class, root)); } AdminConsole.addLink(Diagnostics, "profiler", new ActionURL(MiniProfilerController.ManageAction.class, root)); @@ -2666,6 +2667,15 @@ public PostgresLocksAction() } } + @AdminConsoleAction + public class PostgresTableSizesAction extends AbstractPostgresAction + { + public PostgresTableSizesAction() + { + super(PostgresUserSchema.POSTGRES_TABLE_SIZES_TABLE_NAME); + } + } + @AdminConsoleAction public class DumpHeapAction extends SimpleViewAction { diff --git a/core/src/org/labkey/core/query/PostgresTableSizesTable.java b/core/src/org/labkey/core/query/PostgresTableSizesTable.java new file mode 100644 index 00000000000..16c3254a6ff --- /dev/null +++ b/core/src/org/labkey/core/query/PostgresTableSizesTable.java @@ -0,0 +1,39 @@ +package org.labkey.core.query; + +import org.jetbrains.annotations.NotNull; +import org.labkey.api.data.JdbcType; +import org.labkey.api.data.SQLFragment; +import org.labkey.api.query.ExprColumn; + +/** Backed by pg_locks view */ +public class PostgresTableSizesTable extends AbstractPostgresAdminOnlyTable +{ + public PostgresTableSizesTable(@NotNull PostgresUserSchema userSchema) + { + super(PostgresUserSchema.POSTGRES_TABLE_SIZES_TABLE_NAME, userSchema); + + setDescription("Shows info Postgres table sizes"); + + addColumn(new ExprColumn(this, "table_schema", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".table_schema"), JdbcType.VARCHAR)); + addColumn(new ExprColumn(this, "table_name", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".table_name"), JdbcType.VARCHAR)); + addColumn(new ExprColumn(this, "table_size", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".table_size"), JdbcType.BIGINT)).setFormat("#,##0"); + addColumn(new ExprColumn(this, "index_size", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".index_size"), JdbcType.BIGINT)).setFormat("#,##0"); + addColumn(new ExprColumn(this, "total_size", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".total_size"), JdbcType.BIGINT)).setFormat("#,##0"); + } + + + @Override + public @NotNull SQLFragment getFromSQL() + { + SQLFragment result = new SQLFragment(); + result.append(""" + SELECT + table_schema, + table_name, + pg_table_size('"' || table_schema || '"."' || table_name || '"') AS table_size, + pg_indexes_size('"' || table_schema || '"."' || table_name || '"') AS index_size, + pg_total_relation_size('"' || table_schema || '"."' || table_name || '"') AS total_size + FROM information_schema.tables"""); + return result; + } +} diff --git a/core/src/org/labkey/core/query/PostgresUserSchema.java b/core/src/org/labkey/core/query/PostgresUserSchema.java index dcc6d6191ee..504aa1b72a1 100644 --- a/core/src/org/labkey/core/query/PostgresUserSchema.java +++ b/core/src/org/labkey/core/query/PostgresUserSchema.java @@ -17,6 +17,7 @@ public class PostgresUserSchema extends UserSchema { public static final String POSTGRES_STAT_ACTIVITY_TABLE_NAME = "pg_stat_activity"; public static final String POSTGRES_LOCKS_TABLE_NAME = "pg_locks"; + public static final String POSTGRES_TABLE_SIZES_TABLE_NAME = "pg_tablesizes"; public PostgresUserSchema(User user, Container container) { @@ -36,6 +37,8 @@ public boolean canReadSchema() return new PostgresStatActivityTable(this); if (POSTGRES_LOCKS_TABLE_NAME.equalsIgnoreCase(name)) return new PostgresLocksTable(this); + if (POSTGRES_TABLE_SIZES_TABLE_NAME.equalsIgnoreCase(name)) + return new PostgresTableSizesTable(this); return null; } From 4567289613b387686152ed09810fa205ce82154c Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Mon, 3 Nov 2025 15:26:26 -0800 Subject: [PATCH 2/3] Support tables with quotes in names, BaseColumnInfo --- .../labkey/core/query/PostgresLocksTable.java | 32 ++++++------- .../core/query/PostgresStatActivityTable.java | 47 ++++++++++--------- .../core/query/PostgresTableSizesTable.java | 18 +++---- 3 files changed, 49 insertions(+), 48 deletions(-) diff --git a/core/src/org/labkey/core/query/PostgresLocksTable.java b/core/src/org/labkey/core/query/PostgresLocksTable.java index 0e39c9a56ad..d2c473d3cdc 100644 --- a/core/src/org/labkey/core/query/PostgresLocksTable.java +++ b/core/src/org/labkey/core/query/PostgresLocksTable.java @@ -1,9 +1,9 @@ package org.labkey.core.query; import org.jetbrains.annotations.NotNull; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.JdbcType; import org.labkey.api.data.SQLFragment; -import org.labkey.api.query.ExprColumn; import org.labkey.api.query.QueryForeignKey; /** Backed by pg_locks view */ @@ -16,22 +16,22 @@ public PostgresLocksTable(@NotNull PostgresUserSchema userSchema) setDescription("Shows info about the currently held Postgres locks"); // https://www.postgresql.org/docs/current/view-pg-locks.html - addColumn(new ExprColumn(this, "locktype", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".locktype"), JdbcType.VARCHAR)); - addColumn(new ExprColumn(this, "database", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".database"), JdbcType.INTEGER)); - addColumn(new ExprColumn(this, "relation", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".relation"), JdbcType.INTEGER)); - addColumn(new ExprColumn(this, "page", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".page"), JdbcType.INTEGER)); - addColumn(new ExprColumn(this, "tuple", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".tuple"), JdbcType.INTEGER)); - addColumn(new ExprColumn(this, "virtualxid", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".virtualxid"), JdbcType.VARCHAR)); - addColumn(new ExprColumn(this, "transactionid", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".transactionid"), JdbcType.INTEGER)); - addColumn(new ExprColumn(this, "classid", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".classid"), JdbcType.INTEGER)); - addColumn(new ExprColumn(this, "objid", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".objid"), JdbcType.INTEGER)); - addColumn(new ExprColumn(this, "objsubid", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".objsubid"), JdbcType.INTEGER)); - addColumn(new ExprColumn(this, "virtualtransaction", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".virtualtransaction"), JdbcType.VARCHAR)); - addColumn(new ExprColumn(this, "pid", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".pid"), JdbcType.INTEGER)). + addColumn(new BaseColumnInfo("locktype", this, JdbcType.VARCHAR)); + addColumn(new BaseColumnInfo("database", this, JdbcType.INTEGER)); + addColumn(new BaseColumnInfo("relation", this, JdbcType.INTEGER)); + addColumn(new BaseColumnInfo("page", this, JdbcType.INTEGER)); + addColumn(new BaseColumnInfo("tuple", this, JdbcType.INTEGER)); + addColumn(new BaseColumnInfo("virtualxid", this, JdbcType.VARCHAR)); + addColumn(new BaseColumnInfo("transactionid", this, JdbcType.INTEGER)); + addColumn(new BaseColumnInfo("classid", this, JdbcType.INTEGER)); + addColumn(new BaseColumnInfo("objid", this, JdbcType.INTEGER)); + addColumn(new BaseColumnInfo("objsubid", this, JdbcType.INTEGER)); + addColumn(new BaseColumnInfo("virtualtransaction", this, JdbcType.VARCHAR)); + addColumn(new BaseColumnInfo("pid", this, JdbcType.INTEGER)). setFk(new QueryForeignKey.Builder(userSchema, null).table(PostgresUserSchema.POSTGRES_STAT_ACTIVITY_TABLE_NAME).raw(true)); - addColumn(new ExprColumn(this, "mode", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".mode"), JdbcType.VARCHAR)); - addColumn(new ExprColumn(this, "granted", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".granted"), JdbcType.BOOLEAN)); - addColumn(new ExprColumn(this, "fastpath", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".fastpath"), JdbcType.BOOLEAN)); + addColumn(new BaseColumnInfo("mode", this, JdbcType.VARCHAR)); + addColumn(new BaseColumnInfo("granted", this, JdbcType.BOOLEAN)); + addColumn(new BaseColumnInfo("fastpath", this, JdbcType.BOOLEAN)); } diff --git a/core/src/org/labkey/core/query/PostgresStatActivityTable.java b/core/src/org/labkey/core/query/PostgresStatActivityTable.java index 6afe1df0927..3adc8b2fea6 100644 --- a/core/src/org/labkey/core/query/PostgresStatActivityTable.java +++ b/core/src/org/labkey/core/query/PostgresStatActivityTable.java @@ -4,6 +4,7 @@ import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.ConnectionWrapper; import org.labkey.api.data.Container; @@ -51,37 +52,37 @@ public PostgresStatActivityTable(@NotNull PostgresUserSchema userSchema) setDescription("Shows info about the active Postgres connections and their activity"); // https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW - addColumn(new ExprColumn(this, "datid", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".datid"), JdbcType.INTEGER)); - addColumn(new ExprColumn(this, "datname", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".datname"), JdbcType.VARCHAR)); + addColumn(new BaseColumnInfo("datid", this, JdbcType.INTEGER)); + addColumn(new BaseColumnInfo("datname", this, JdbcType.VARCHAR)); - ExprColumn pidColumn = new ExprColumn(this, "pid", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".pid"), JdbcType.INTEGER); + BaseColumnInfo pidColumn = new BaseColumnInfo("pid", this, JdbcType.INTEGER); pidColumn.setKeyField(true); addColumn(pidColumn); - addColumn(new ExprColumn(this, "leader_pid", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".leader_pid"), JdbcType.INTEGER)); - addColumn(new ExprColumn(this, "usesysid", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".usesysid"), JdbcType.INTEGER)); - addColumn(new ExprColumn(this, "usename", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".usename"), JdbcType.VARCHAR)); - addColumn(new ExprColumn(this, "application_name", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".application_name"), JdbcType.VARCHAR)); - addColumn(new ExprColumn(this, "client_addr", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".client_addr"), JdbcType.VARCHAR)); - addColumn(new ExprColumn(this, "client_hostname", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".client_hostname"), JdbcType.VARCHAR)); - addColumn(new ExprColumn(this, "client_port", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".client_port"), JdbcType.INTEGER)); - addColumn(new ExprColumn(this, "backend_start", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".backend_start"), JdbcType.TIMESTAMP)); - addColumn(new ExprColumn(this, "xact_start", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".xact_start"), JdbcType.TIMESTAMP)); - addColumn(new ExprColumn(this, "query_start", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".query_start"), JdbcType.TIMESTAMP)); - addColumn(new ExprColumn(this, "state_change", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".state_change"), JdbcType.TIMESTAMP)); - addColumn(new ExprColumn(this, "wait_event_type", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".wait_event_type"), JdbcType.VARCHAR)); - addColumn(new ExprColumn(this, "wait_event", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".wait_event"), JdbcType.VARCHAR)); - addColumn(new ExprColumn(this, "state", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".state"), JdbcType.VARCHAR)); - addColumn(new ExprColumn(this, "backend_xid", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".backend_xid"), JdbcType.INTEGER)); - addColumn(new ExprColumn(this, "backend_xmin", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".backend_xmin"), JdbcType.INTEGER)); - addColumn(new ExprColumn(this, "query", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".query"), JdbcType.VARCHAR)); - addColumn(new ExprColumn(this, "backend_type", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".backend_type"), JdbcType.VARCHAR)); + addColumn(new BaseColumnInfo("leader_pid", this, JdbcType.INTEGER)); + addColumn(new BaseColumnInfo("usesysid", this, JdbcType.INTEGER)); + addColumn(new BaseColumnInfo("usename", this, JdbcType.VARCHAR)); + addColumn(new BaseColumnInfo("application_name", this, JdbcType.VARCHAR)); + addColumn(new BaseColumnInfo("client_addr", this, JdbcType.VARCHAR)); + addColumn(new BaseColumnInfo("client_hostname", this, JdbcType.VARCHAR)); + addColumn(new BaseColumnInfo("client_port", this, JdbcType.INTEGER)); + addColumn(new BaseColumnInfo("backend_start", this, JdbcType.TIMESTAMP)); + addColumn(new BaseColumnInfo("xact_start", this, JdbcType.TIMESTAMP)); + addColumn(new BaseColumnInfo("query_start", this, JdbcType.TIMESTAMP)); + addColumn(new BaseColumnInfo("state_change", this, JdbcType.TIMESTAMP)); + addColumn(new BaseColumnInfo("wait_event_type", this, JdbcType.VARCHAR)); + addColumn(new BaseColumnInfo("wait_event", this, JdbcType.VARCHAR)); + addColumn(new BaseColumnInfo("state", this, JdbcType.VARCHAR)); + addColumn(new BaseColumnInfo("backend_xid", this, JdbcType.INTEGER)); + addColumn(new BaseColumnInfo("backend_xmin", this, JdbcType.INTEGER)); + addColumn(new BaseColumnInfo("query", this, JdbcType.VARCHAR)); + addColumn(new BaseColumnInfo("backend_type", this, JdbcType.VARCHAR)); // Our calculated values var threadCol = addColumn(new ExprColumn(this, "threadsAndRequests", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".pid"), JdbcType.INTEGER)); threadCol.setDisplayColumnFactory(ThreadDisplayColumn::new); - addColumn(new ExprColumn(this, "running_time_ms", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".running_time_ms"), JdbcType.INTEGER)); - addColumn(new ExprColumn(this, "blocked_by", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".blocked_by"), JdbcType.VARCHAR)); + addColumn(new BaseColumnInfo("running_time_ms", this, JdbcType.INTEGER)); + addColumn(new BaseColumnInfo("blocked_by", this, JdbcType.VARCHAR)); setDefaultVisibleColumns(Arrays.asList( pidColumn.getFieldKey(), diff --git a/core/src/org/labkey/core/query/PostgresTableSizesTable.java b/core/src/org/labkey/core/query/PostgresTableSizesTable.java index 16c3254a6ff..554a44e85e8 100644 --- a/core/src/org/labkey/core/query/PostgresTableSizesTable.java +++ b/core/src/org/labkey/core/query/PostgresTableSizesTable.java @@ -1,9 +1,9 @@ package org.labkey.core.query; import org.jetbrains.annotations.NotNull; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.JdbcType; import org.labkey.api.data.SQLFragment; -import org.labkey.api.query.ExprColumn; /** Backed by pg_locks view */ public class PostgresTableSizesTable extends AbstractPostgresAdminOnlyTable @@ -14,11 +14,11 @@ public PostgresTableSizesTable(@NotNull PostgresUserSchema userSchema) setDescription("Shows info Postgres table sizes"); - addColumn(new ExprColumn(this, "table_schema", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".table_schema"), JdbcType.VARCHAR)); - addColumn(new ExprColumn(this, "table_name", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".table_name"), JdbcType.VARCHAR)); - addColumn(new ExprColumn(this, "table_size", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".table_size"), JdbcType.BIGINT)).setFormat("#,##0"); - addColumn(new ExprColumn(this, "index_size", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".index_size"), JdbcType.BIGINT)).setFormat("#,##0"); - addColumn(new ExprColumn(this, "total_size", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".total_size"), JdbcType.BIGINT)).setFormat("#,##0"); + addColumn(new BaseColumnInfo("table_schema", this, JdbcType.VARCHAR)); + addColumn(new BaseColumnInfo("table_name", this, JdbcType.VARCHAR)); + addColumn(new BaseColumnInfo("table_size", this, JdbcType.BIGINT)).setFormat("#,##0"); + addColumn(new BaseColumnInfo("index_size", this, JdbcType.BIGINT)).setFormat("#,##0"); + addColumn(new BaseColumnInfo("total_size", this, JdbcType.BIGINT)).setFormat("#,##0"); } @@ -30,9 +30,9 @@ public PostgresTableSizesTable(@NotNull PostgresUserSchema userSchema) SELECT table_schema, table_name, - pg_table_size('"' || table_schema || '"."' || table_name || '"') AS table_size, - pg_indexes_size('"' || table_schema || '"."' || table_name || '"') AS index_size, - pg_total_relation_size('"' || table_schema || '"."' || table_name || '"') AS total_size + pg_table_size(quote_ident(table_schema) || '.' || quote_ident(table_name)) AS table_size, + pg_indexes_size(quote_ident(table_schema) || '.' || quote_ident(table_name)) AS index_size, + pg_total_relation_size(quote_ident(table_schema) || '.' || quote_ident(table_name)) AS total_size FROM information_schema.tables"""); return result; } From ab2a84a27b525b2704fc8606014a6759b073380f Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Mon, 3 Nov 2025 16:00:40 -0800 Subject: [PATCH 3/3] Filter out PG schemas --- core/src/org/labkey/core/query/PostgresTableSizesTable.java | 4 ++-- core/src/org/labkey/core/query/PostgresUserSchema.java | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/org/labkey/core/query/PostgresTableSizesTable.java b/core/src/org/labkey/core/query/PostgresTableSizesTable.java index 554a44e85e8..7f31ba96b9b 100644 --- a/core/src/org/labkey/core/query/PostgresTableSizesTable.java +++ b/core/src/org/labkey/core/query/PostgresTableSizesTable.java @@ -21,7 +21,6 @@ public PostgresTableSizesTable(@NotNull PostgresUserSchema userSchema) addColumn(new BaseColumnInfo("total_size", this, JdbcType.BIGINT)).setFormat("#,##0"); } - @Override public @NotNull SQLFragment getFromSQL() { @@ -33,7 +32,8 @@ public PostgresTableSizesTable(@NotNull PostgresUserSchema userSchema) pg_table_size(quote_ident(table_schema) || '.' || quote_ident(table_name)) AS table_size, pg_indexes_size(quote_ident(table_schema) || '.' || quote_ident(table_name)) AS index_size, pg_total_relation_size(quote_ident(table_schema) || '.' || quote_ident(table_name)) AS total_size - FROM information_schema.tables"""); + FROM information_schema.tables + WHERE table_schema NOT IN ('public', 'information_schema') AND table_schema NOT LIKE 'pg_%'"""); return result; } } diff --git a/core/src/org/labkey/core/query/PostgresUserSchema.java b/core/src/org/labkey/core/query/PostgresUserSchema.java index 504aa1b72a1..6ca8a60c00b 100644 --- a/core/src/org/labkey/core/query/PostgresUserSchema.java +++ b/core/src/org/labkey/core/query/PostgresUserSchema.java @@ -46,6 +46,9 @@ public boolean canReadSchema() @Override public Set getTableNames() { - return Set.of(POSTGRES_STAT_ACTIVITY_TABLE_NAME, POSTGRES_LOCKS_TABLE_NAME); + return Set.of( + POSTGRES_LOCKS_TABLE_NAME, + POSTGRES_STAT_ACTIVITY_TABLE_NAME, + POSTGRES_TABLE_SIZES_TABLE_NAME); } }