Note
This view was introduced in OceanBase Database V4.3.4.
Purpose
The CDB_OB_TABLE_SPACE_USAGE view is used to display the size of all user tables under all tenants based on the Leader replica in a multi-replica environment.
Columns
| Column | Type | Nullable? | Description |
|---|---|---|---|
| TENANT_ID | varchar(128) | NO | Tenant ID |
| TABLE_ID | bigint(20) | NO | Table ID |
| TENANT_NAME | varchar(128) | NO | Tenant name |
| DATABASE_NAME | varchar(128) | NO | Database name |
| TABLE_NAME | varchar(256) | NO | Table name |
| OCCUPY_SIZE | decimal(42,0) | NO | The amount of data written to disk after table compression, in bytes. |
| REQUIRED_SIZE | decimal(42,0) | NO | The actual disk space occupied by the data written to disk after table compression, in bytes. |
Sample query
In Shared-Nothing mode, the sys tenant queries the size of all user tables under all tenants.
obclient [oceanbase]> SELECT * FROM oceanbase.CDB_OB_TABLE_SPACE_USAGE LIMIT 10;
The query result is as follows:
+-----------+----------+-------------+---------------+---------------------+-------------+---------------+
| TENANT_ID | TABLE_ID | TENANT_NAME | DATABASE_NAME | TABLE_NAME | OCCUPY_SIZE | REQUIRED_SIZE |
+-----------+----------+-------------+---------------+---------------------+-------------+---------------+
| 1 | 500006 | sys | test | T1 | 1094 | 8192 |
| 1 | 500007 | sys | test | __idx_500006_IDX_C1 | 926 | 8192 |
| 1 | 500008 | sys | mysql | t2_m_lr | 2088 | 16384 |
| 1 | 500009 | sys | oceanbase | __idx_500008_IDX_C1 | 881 | 8192 |
| 1 | 500010 | sys | oceanbase | test1 | 493 | 4096 |
| 1 | 500011 | sys | oceanbase | __idx_500010_b_idx | 493 | 4096 |
| 1 | 500012 | sys | oceanbase | test2 | 493 | 4096 |
| 1 | 500013 | sys | oceanbase | __idx_500012_b_idx | 493 | 4096 |
| 1002 | 500008 | mysql001 | mysql | t2_m_lr | 8856 | 73728 |
| 1002 | 500051 | mysql001 | test | t1 | 1233 | 8192 |
+-----------+----------+-------------+---------------+---------------------+-------------+---------------+
10 rows in set