Show table size fo MySQL and Postgres #552

This commit is contained in:
SPRINX0\prochazka
2025-11-21 15:56:26 +01:00
parent 6e0b3e5cdc
commit 4600fa9f32
6 changed files with 27 additions and 11 deletions

View File

@@ -3,6 +3,7 @@ select
TABLE_NAME as pureName,
TABLE_TYPE as objectType,
TABLE_ROWS as tableRowCount,
DATA_LENGTH + INDEX_LENGTH as sizeBytes,
case when ENGINE='InnoDB' then CREATE_TIME else coalesce(UPDATE_TIME, CREATE_TIME) end as modifyDate
from information_schema.tables
where TABLE_SCHEMA = '#DATABASE#'

View File

@@ -4,6 +4,7 @@ select
TABLE_ROWS as tableRowCount,
ENGINE as tableEngine,
TABLE_COMMENT as objectComment,
DATA_LENGTH + INDEX_LENGTH as sizeBytes,
case when ENGINE='InnoDB' then CREATE_TIME else coalesce(UPDATE_TIME, CREATE_TIME) end as modifyDate
from information_schema.tables
where TABLE_SCHEMA = '#DATABASE#' and (TABLE_TYPE='BASE TABLE' or TABLE_TYPE='SYSTEM VERSIONED') and TABLE_NAME =OBJECT_ID_CONDITION;

View File

@@ -255,6 +255,7 @@ class Analyser extends DatabaseAnalyser {
const newTable = {
pureName: table.pure_name,
schemaName: table.schema_name,
sizeBytes: table.size_bytes,
objectId: `tables:${table.schema_name}.${table.pure_name}`,
contentHash: table.hash_code_columns ? `${table.hash_code_columns}-${table.hash_code_constraints}` : null,
};
@@ -410,6 +411,7 @@ class Analyser extends DatabaseAnalyser {
objectId: `tables:${x.schema_name}.${x.pure_name}`,
pureName: x.pure_name,
schemaName: x.schema_name,
sizeBytes: x.size_bytes,
contentHash: `${x.hash_code_columns}-${x.hash_code_constraints}`,
}))
: null,

View File

@@ -1,5 +1,6 @@
module.exports = `
select infoTables.table_schema as "schema_name", infoTables.table_name as "pure_name"
select infoTables.table_schema as "schema_name", infoTables.table_name as "pure_name",
pg_relation_size('"'||infoTables.table_schema||'"."'||infoTables.table_name||'"') as "size_bytes"
from information_schema.tables infoTables
where infoTables.table_type not like '%VIEW%'
and ('tables:' || infoTables.table_schema || '.' || infoTables.table_name) =OBJECT_ID_CONDITION

View File

@@ -16,7 +16,8 @@ select infoTables.table_schema as "schema_name", infoTables.table_name as "pure_
)) as "hash_code_constraints"
from information_schema.table_constraints infoConstraints
where infoConstraints.table_schema = infoTables.table_schema and infoConstraints.table_name = infoTables.table_name
)
),
pg_relation_size('"'||infoTables.table_schema||'"."'||infoTables.table_name||'"') as "size_bytes"
from information_schema.tables infoTables
where infoTables.table_type not like '%VIEW%'