-
Notifications
You must be signed in to change notification settings - Fork 7
Admin Console report to show table sizes; metrics for schema sizes #7170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Admin Console report to show table sizes; metrics for schema sizes #7170
Conversation
|
ERROR: A pull request from |
|
|
||
| setDescription("Shows info Postgres table sizes"); | ||
|
|
||
| addColumn(new ExprColumn(this, "table_schema", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".table_schema"), JdbcType.VARCHAR)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the default behavior of BaseColumnInfo (no need for ExprColumn and SQLFragment). See BaseColumnInfo.getValueSql(String tableAliasName)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. Thanks. I updated all three special PG tables
| SELECT | ||
| table_schema, | ||
| table_name, | ||
| pg_table_size('"' || table_schema || '"."' || table_name || '"') AS table_size, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, this syntax is so weird. PG is very vague about how a VARCHAR gets converted to OID. This is also slightly weirder in that you're using the information_schema where OID doesn't exist.
Something like this against the native schema let's you get the OID directly.
SELECT pg_namespace.nspname as schema_name, pg_class.relname as table_name, pg_table_size(pg_class.oid)
FROM pg_class JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid
WHERE pg_class.relkind = 'r' and nspname NOT IN ('pg_catalog', 'information_schema')
ORDER BY schema_name, table_name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a SQL problem with the original. I just don't know what PG will do when converting the generated string to an OID when the table has double-quotes in the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arg. Stupid quotes.
I created a horrible schema and table name. I verified that quote_ident fixes the problem and resolves to regclass/OID correctly.
labkey-matthewb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved. Comments for you consideration.
|
@labkey-adam I added a filter to omit those PG internal schemas |
Rationale
If we know the sizes of tables we can make better choices about infrastructure and better estimate usage. Limited to Postgres.
Changes
modules.Core.databaseSchemaSizesmetric to roll up table sizes by schemaTasks 📍
SqlDialect.isSystemSchema().