MisterRaindrop commented on code in PR #2064:
URL: https://github.com/apache/cloudberry/pull/2064#discussion_r4144704339
##########
mcp-server/src/cbmcp/database.py:
##########
@@ -644,14 +644,11 @@ async def get_table_bloat_info(self) -> list[dict]:
records = await conn.fetch(
"SELECT "
"schemaname, "
- "relname as tablename, "
-
"pg_size_pretty(pg_total_relation_size(schemaname||'.'||relname)) as
total_size, "
- "round(100 * (relpages - (relpages * fillfactor / 100)) /
relpages, 2) as bloat_ratio "
- "FROM pg_class c "
- "JOIN pg_namespace n ON n.oid = c.relnamespace "
- "JOIN pg_stat_user_tables s ON s.relid = c.oid "
- "WHERE c.relkind = 'r' AND n.nspname NOT LIKE 'pg_%' "
- "ORDER BY bloat_ratio DESC "
+ "relname AS tablename, "
+ "pg_size_pretty(pg_total_relation_size(relid)) AS total_size, "
+ "round(100.0 * n_dead_tup / GREATEST(n_live_tup + n_dead_tup,
1), 2)::float8 AS bloat_ratio "
+ "FROM pg_stat_user_tables "
Review Comment:
Could we preserve the original relation-type and schema filters here? In
Cloudberry, `pg_stat_user_tables` is derived from `pg_stat_all_tables`, which
also contains materialized views, partition roots, and AO auxiliary relations,
and it does not exclude the `pg_aoseg` schema.
The previous query restricted the result to `c.relkind = 'r'` and excluded
`pg_%` schemas. Without equivalent filtering, internal relations or partition
roots can enter the top 20 and crowd out actual user tables. Please consider
joining `pg_class`/`pg_namespace` and restoring those filters.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]