SELECT /*+ query_timeout(30000000) */
a.DATABASE_NAME,
a.TABLE_NAME,
sum(case when b.nested_offset = 0 then IFNULL(b.data_block_count + b.index_block_count + b.linked_block_count, 0) * 2 * 1024 * 1024 else IFNULL(b.size, 0) end) / 1024.0 / 1024 / 1024 as data_size_in_GB
FROM oceanbase.CDB_OB_TABLE_LOCATIONS a
INNER JOIN oceanbase.__all_virtual_table_mgr b
ON a.svr_ip = b.svr_ip
AND a.svr_port = b.svr_port
AND a.tenant_id = b.tenant_id
AND a.LS_ID = b.LS_ID
AND a.TABLET_ID = b.TABLET_ID
AND a.role = 'LEADER'
AND a.tenant_id = ${租户ID}
AND a.DATABASE_NAME = 'A1'
AND b.table_type >= 10
AND b.size > 0
GROUP BY a.TABLE_ID
ORDER BY data_size_in_GB DESC
LIMIT 20;
SELECT
t1.tenant_name,
t4.resource_pool_id,
COUNT(t2.unit_id) AS unit_count,
t4.unit_config_id,
GROUP_CONCAT(DISTINCT concat(svr_ip, ":", svr_port)) AS svr_ips
FROM OCEANBASE.DBA_OB_TENANTS t1
JOIN OCEANBASE.DBA_OB_RESOURCE_POOLS t4 ON t1.tenant_id = t4.tenant_id
LEFT JOIN OCEANBASE.GV$OB_UNITS t2 ON t4.resource_pool_id = t2.resource_pool_id
GROUP BY t1.tenant_name, t4.resource_pool_id, t4.unit_config_id;
SELECT /*+ query_timeout(30000000) */
a.DATABASE_NAME,
a.TABLE_NAME,
sum(case when b.nested_offset = 0 then IFNULL(b.data_block_count + b.index_block_count + b.linked_block_count, 0) * 2 * 1024 * 1024 else IFNULL(b.size, 0) end) / 1024.0 / 1024 / 1024 as data_size_in_GB
FROM oceanbase.CDB_OB_TABLE_LOCATIONS a
INNER JOIN oceanbase.__all_virtual_table_mgr b
ON a.svr_ip = b.svr_ip
AND a.svr_port = b.svr_port
AND a.tenant_id = b.tenant_id
AND a.LS_ID = b.LS_ID
AND a.TABLET_ID = b.TABLET_ID
AND a.role = ‘LEADER’
AND a.tenant_id = 1080
AND a.DATABASE_NAME = ‘dpdb’
AND b.table_type >= 10
AND b.size > 0
GROUP BY a.TABLE_ID
ORDER BY data_size_in_GB DESC
LIMIT 20;
SELECT
t1.tenant_name,
t4.resource_pool_id,
COUNT(t2.unit_id) AS unit_count,
t4.unit_config_id,
GROUP_CONCAT(DISTINCT concat(svr_ip, “:”, svr_port)) AS svr_ips
FROM OCEANBASE.DBA_OB_TENANTS t1
JOIN OCEANBASE.DBA_OB_RESOURCE_POOLS t4 ON t1.tenant_id = t4.tenant_id
LEFT JOIN OCEANBASE.GV$OB_UNITS t2 ON t4.resource_pool_id = t2.resource_pool_id
GROUP BY t1.tenant_name, t4.resource_pool_id, t4.unit_config_id;
失败原因:
ErrorCode = 1054, SQLState = 42S22, Details = Unknown column ‘t2.resource_pool_id’ in ‘on clause’ If column exists but type cannot be identified (example ‘select ? field1 from dual’). Use CAST function to solve this problem (example ‘select CAST(? as integer) field1 from dual’)
SELECT
t1.tenant_name,
rp.resource_pool_id,
COUNT(u.unit_id) AS unit_count,
rp.unit_config_id,
GROUP_CONCAT(DISTINCT CONCAT(u.svr_ip, ":", u.svr_port)) AS svr_ips
FROM OCEANBASE.DBA_OB_TENANTS t1
JOIN OCEANBASE.DBA_OB_RESOURCE_POOLS rp ON t1.tenant_id = rp.tenant_id
LEFT JOIN OCEANBASE.GV$OB_UNITS u ON rp.resource_pool_name = u.resource_pool_name
GROUP BY t1.tenant_name, rp.resource_pool_id, rp.unit_config_id;
SELECT /*+ query_timeout(30000000) */
a.DATABASE_NAME,a.table_type,
case when a.TABLE_TYPE=‘USER TABLE’ THEN table_name when a.TABLE_TYPE=‘INDEX’ THEN INDEX_NAME else table_name end as table_name,
sum(case when b.nested_offset = 0 then IFNULL(b.data_block_count + b.index_block_count + b.linked_block_count, 0) * 2 * 1024 * 1024 else IFNULL(b.size, 0) end) / 1024.0 / 1024 / 1024 as data_size_in_GB
FROM oceanbase.CDB_OB_TABLE_LOCATIONS a
INNER JOIN oceanbase.__all_virtual_table_mgr b
ON a.svr_ip = b.svr_ip
AND a.svr_port = b.svr_port
AND a.tenant_id = b.tenant_id
AND a.LS_ID = b.LS_ID
AND a.TABLET_ID = b.TABLET_ID
AND a.role = ‘LEADER’
AND a.tenant_id = ${租户ID}
AND a.DATABASE_NAME = ‘${database_name}’
AND b.table_type >= 10
AND b.size > 0
GROUP BY a.TABLE_ID
ORDER BY data_size_in_GB DESC
LIMIT 20;
仍然报错:
SELECT
t1.tenant_name,
rp.resource_pool_id,
COUNT(u.unit_id) AS unit_count,
rp.unit_config_id,
GROUP_CONCAT(DISTINCT CONCAT(u.svr_ip, “:”, u.svr_port)) AS svr_ips
FROM OCEANBASE.DBA_OB_TENANTS t1
JOIN OCEANBASE.DBA_OB_RESOURCE_POOLS rp ON t1.tenant_id = rp.tenant_id
LEFT JOIN OCEANBASE.GV$OB_UNITS u ON rp.resource_pool_id = u.resource_pool_name
GROUP BY t1.tenant_name, rp.resource_pool_id, rp.unit_config_id;
ErrorCode = 1054, SQLState = 42S22, Details = Unknown column ‘rp.resource_pool_name’ in ‘on clause’ If column exists but type cannot be identified (example ‘select ? field1 from dual’). Use CAST function to solve this problem (example ‘select CAST(? as integer) field1 from dual’)
SELECT
t1.tenant_name,
rp.RESOURCE_POOL_ID,
COUNT(u.unit_id) AS unit_count,
rp.unit_config_id,
GROUP_CONCAT(DISTINCT CONCAT(u.svr_ip, “:”, u.svr_port)) AS svr_ips
FROM
oceanbase.DBA_OB_TENANTS t1
JOIN oceanbase.DBA_OB_RESOURCE_POOLS rp ON t1.tenant_id = rp.tenant_id
LEFT JOIN oceanbase.DBA_OB_UNITS u ON rp.RESOURCE_POOL_ID = u.RESOURCE_POOL_ID
group by
t1.tenant_name,
rp.RESOURCE_POOL_ID,
rp.unit_config_id