diff --git a/pkg/frontend/show_account.go b/pkg/frontend/show_account.go index 672046f7c485..80593510058b 100644 --- a/pkg/frontend/show_account.go +++ b/pkg/frontend/show_account.go @@ -74,6 +74,10 @@ const ( idxOfComment = 5 // left the `size` as a placeholder, the value will be embedding later + // index table(__index_xxx): do not counting it into the `table_count`, but need its size. + // mo_increment_columns: do not counting it into the `table_count`, but need its size. + // subscription db: do not counting it into the `db_count`, and its size + // sys table(mo_database, mo_tables, mo_column): counting them into the `table_count`, and need their sizes getTableStatsFormatV2 = "select " + "( select " + " mu2.user_name as `admin_name` " + @@ -88,7 +92,9 @@ const ( "cast(0 as double) as `size` " + "from " + "mo_catalog.mo_tables as mt, mo_catalog.mo_database as md " + - "where mt.relkind != '%s' and mt.account_id = %d;" + "where md.dat_type != 'subscription' " + + "and mt.relkind in ('v','r','e','cluster') " + + "and mt.account_id in (%d, %d);" // column index in the result set generated by // the sql getTableStatsFormatV2 @@ -130,7 +136,8 @@ func getSqlForAccountInfo(accountId uint64) string { } func getSqlForTableStats(accountId int32) string { - return fmt.Sprintf(getTableStatsFormatV2, catalog.SystemPartitionRel, accountId) + //return fmt.Sprintf(getTableStatsFormatV2, catalog.SystemPartitionRel, accountId) + return fmt.Sprintf(getTableStatsFormatV2, accountId, sysAccountID) } func requestStorageUsage(ses *Session, accIds [][]int32) (resp any, tried bool, err error) { diff --git a/test/distributed/cases/tenant/tenant.result b/test/distributed/cases/tenant/tenant.result index 925a94a37b91..17f772516e29 100644 --- a/test/distributed/cases/tenant/tenant.result +++ b/test/distributed/cases/tenant/tenant.result @@ -8,8 +8,8 @@ create account tenant_test admin_name = 'root' open comment 'tenant_test'; SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. syntax error at line 1 column 51 near " open comment 'tenant_test';"; show accounts; account_name admin_name created status suspended_time db_count table_count size comment -tenant_test root 2023-11-12 12:43:41 open null 5 56 0.0 tenant_test -sys root 2023-11-12 03:33:41 open null 7 84 13.256612 system account +tenant_test root 2023-11-12 12:43:41 open null 5 50 0.0 tenant_test +sys root 2023-11-12 03:33:41 open null 7 72 13.256612 system account drop account if exists tenant_test; select account_id,relname,relkind from mo_catalog.mo_tables where reldatabase = 'mo_catalog' and relname not like '__mo_index_unique__%' order by relname; account_id relname relkind