Note
The view name has been changed from V$MEMORY to V$OB_MEMORY since V4.0.0.
Overview
Displays the memory statistics of all tenants on the current node.
Columns
Field |
Type |
Nullable |
Description |
|---|---|---|---|
| TENANT_ID | bigint(20) | NO | Tenant ID |
| SVR_IP | varchar(46) | NO | Server IP Address |
| SVR_PORT | bigint(20) | NO | Server Port Number |
| CTX_NAME | varchar(256) | NO | Name of the CTX to Which Memory Belongs |
| MOD_NAME | varchar(256) | NO | Name of the module to which the memory belongs |
| COUNT | decimal(20,0) | NO | The difference between memory allocation and release, that is, the number of memory units currently in use by this module. |
| HOLD | decimal(20,0) | NO | The memory size currently occupied by this module. |
| USED | decimal(20,0) | NO | The memory usage of the module, in bytes. |
CTX_NAME field values
The following table describes the common memory context names and their meanings:
CTX_NAME |
Description |
|---|---|
| DEFAULT_CTX_ID | Indicates the context ID of the unpartitioned memory collection. |
| MEMSTORE_CTX_ID | Represents the user's MemTable data context ID. |
| TRANS_CTX_MGR_ID | Transaction Context ID |
| PLAN_CACHE_CTX_ID | Execution plan cache context ID. |
| GLIBC | Indicates the memory allocated using the Glibc Malloc interface. |
| CO_STACK | Represents the memory of the thread execution stack. |
| KVSTORE_CACHE_ID | Represents the dynamic scalable cache ID. |
| META_OBJ_CTX_ID | Represents the memory for storing metadata, such as macroblock meta. |
| TX_CALLBACK_CTX_ID | Represents the transaction callback context ID. It is used to record some modifications during transaction execution, so that corresponding data can be found for operations during transaction commit or rollback. |
| LOB_CTX_ID | Indicates the allocator ID in the OBlobManager. |
| PS_CACHE_CTX_ID | meansPREPARE stmt_name FROM preparable_stmtCache ID of the statement |
| TX_DATA_TABLE | Represents a transaction data table. It stores the status of completed transactions and is used for queries in scenarios such as minor compactions and FAST COMMIT. |
| MDS_DATA_ID | Memory ID of multi-source data |
| LIBEASY | Indicates the memory of the network framework (EASY). |
| LOGGER_CTX_ID | Represents the program log memory context ID. |
| RPC_CTX_ID | Represents the RPC framework memory context ID. |
| PKT_NIO | Represents the memory of the network framework (pkt_nio). |
| SCHEMA_SERVICE | Represents the memory for schema metadata, such as tables and databases. |
Mapping between CTX_NAME and MOD_NAME
The common correspondence between CTX_NAME and MOD_NAME is as follows:
CTX_NAME |
MOD_NAME |
TENANT |
|---|---|---|
| DEFAULT_CTX_ID |
|
ALL |
|
500 | |
| SQL_EXEC_CTX_ID |
|
ALL |
| WORK_AREA |
|
|
| PLAN_CACHE_CTX_ID |
|
|
| TRANS_CTX_MGR_ID |
|
|
| TX_CALLBACK_CTX_ID | MemtableCallbac: the module related to memory table callback. | |
| REPLAY_STATUS_CTX_ID | ReplayStatus: the status of the replay module. | |
| CO_STACK | CO_STACK: Coroutine stack-related modules | 500 |
| STORAGE_LONG_TERM_META_CTX_ID |
|
|
| STORAGE_SHORT_TERM_META_CTX_ID |
|
|
| ALL | OB_COMMON_ARRAY: OceanBase common array | ALL |
Impact of common SQL operations on memory CTX
In OceanBase Database, each SQL execution or operation corresponds to a specific CTX. Due to differences in data volume and operation complexity, the memory used by a CTX may lead to increased memory consumption. The following are some common SQL executions or operations that may cause the usage of memory for certain CTXs to increase:
Sorting large volumes of data (ORDER BY, GROUP BY, etc.): Sorting operations require loading data into memory for processing, which may lead to increased memory usage in the PLAN_CACHE_CTX_ID, MEMSTORE_CTX_ID, and DEFAULT_CTX_ID contexts.
Aggregation of large data volumes (SUM, AVG, MAX, MIN, etc.): Aggregation operations require loading data into memory for computation, which may lead to increased memory usage in the PLAN_CACHE_CTX_ID, MEMSTORE_CTX_ID, and DEFAULT_CTX_ID contexts.
Connections (JOINs) involving large volumes of data: The join operation requires loading data into memory for matching, which may lead to increased memory usage in the PLAN_CACHE_CTX_ID, MEMSTORE_CTX_ID, and DEFAULT_CTX_ID contexts.
Queries with large data volumes (SELECT): The query operation needs to load data into memory for filtering and sorting, which may lead to increased memory usage in PLAN_CACHE_CTX_ID, MEMSTORE_CTX_ID, and DEFAULT_CTX_ID.
Writing large volumes of data (INSERT, UPDATE, DELETE, etc.): Write operations require transaction management and processing, which may lead to increased memory usage in TRANS_CTX_MGR_ID, MEMSTORE_CTX_ID, and DEFAULT_CTX_ID.
Logs with large volumes (such as REDO, UNDO, and BINLOG logs): Log operations require loading data into memory for processing, which may lead to increased memory usage in the TRANS_CTX_MGR_ID, DEFAULT_CTX_ID, LOB_CTX_ID, and TX_DATA_TABLE variables.
Sample query
Query the memory statistics of the tenant with ID 1002 on the current node in the sys tenant, and display the first 10 records.
obclient [oceanbase]> SELECT * FROM V$OB_MEMORY WHERE TENANT_ID=1002 LIMIT 10;
The query result is as follows:
+-----------+----------------+----------+----------------+-----------------+-------+-----------+-----------+
| TENANT_ID | SVR_IP | SVR_PORT | CTX_NAME | MOD_NAME | COUNT | HOLD | USED |
+-----------+----------------+----------+----------------+-----------------+-------+-----------+-----------+
| 1002 | 172.xx.xxx.xxx | 2882 | CO_STACK | CoStack | 196 | 101154816 | 100966656 |
| 1002 | 172.xx.xxx.xxx | 2882 | CO_STACK | KvstorCacheMb | 0 | 0 | 0 |
| 1002 | 172.xx.xxx.xxx | 2882 | DEFAULT_CTX_ID | ApplySrv | 1 | 409600 | 401408 |
| 1002 | 172.xx.xxx.xxx | 2882 | DEFAULT_CTX_ID | APPLY_STATUS | 1 | 8128 | 7936 |
| 1002 | 172.xx.xxx.xxx | 2882 | DEFAULT_CTX_ID | ArcFetchQueue | 1 | 8540160 | 8519680 |
| 1002 | 172.xx.xxx.xxx | 2882 | DEFAULT_CTX_ID | ArcSenderQueue | 1 | 933888 | 931072 |
| 1002 | 172.xx.xxx.xxx | 2882 | DEFAULT_CTX_ID | AsyncFreezeTabl | 1 | 114688 | 111096 |
| 1002 | 172.xx.xxx.xxx | 2882 | DEFAULT_CTX_ID | Autoincrement | 1 | 40960 | 37032 |
| 1002 | 172.xx.xxx.xxx | 2882 | DEFAULT_CTX_ID | Backup | 1 | 16384 | 12344 |
| 1002 | 172.xx.xxx.xxx | 2882 | DEFAULT_CTX_ID | BackupIOPerMgr | 1 | 1152 | 960 |
+-----------+----------------+----------+----------------+-----------------+-------+-----------+-----------+
10 rows in set
