Note
- The view name has been changed from V$MEMORY to V$OB_MEMORY since V4.0.0.
- This view is currently supported only in MySQL-compatible mode. In Oracle-compatible mode, the query result will be empty.
Overview
Displays the memory statistics of the current tenant on the current node.
Columns
Field |
Type |
Nullable |
Description |
|---|---|---|---|
| CON_ID | NUMBER(38) | NO | Tenant ID |
| SVR_IP | VARCHAR2(46) | NO | Server IP Address |
| SVR_PORT | NUMBER(38) | NO | Server Port Number |
| CTX_NAME | VARCHAR2(256) | NO | Name of the CTX to Which Memory Belongs |
| MOD_NAME | VARCHAR2(256) | NO | Name of the module to which the memory belongs |
| COUNT | NUMBER | NO | The difference between the allocated and freed memory, indicating the number of memory units currently in use by this module. |
| HOLD | NUMBER | NO | The memory size currently occupied by this module |
| USED | NUMBER | NO | The memory usage of the module, in bytes. |
CTX_NAME field values
The following table describes the common memory CTX 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 | denotesPREPARE 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 module related to the replay status. | |
| 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 the CTX may lead to increased memory consumption. The following are some common SQL executions or operations that may cause the usage of memory by 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 PLAN_CACHE_CTX_ID, MEMSTORE_CTX_ID, and DEFAULT_CTX_ID.
Connections (JOINs) with large data volumes: 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 the PLAN_CACHE_CTX_ID, MEMSTORE_CTX_ID, and DEFAULT_CTX_ID contexts.
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 data 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
The user tenant queries the memory statistics of the current node for the current tenant, displaying the first 10 records.
obclient [SYS]> SELECT * FROM SYS.V$OB_MEMORY WHERE ROWNUM <= 10;
The query result is as follows:
+-----------+----------------+----------+-------------------------------+-----------------+-------+-----------+-----------+
| TENANT_ID | SVR_IP | SVR_PORT | CTX_NAME | MOD_NAME | COUNT | HOLD | USED |
+-----------+----------------+----------+-------------------------------+-----------------+--------+-----------+-----------+
| 1004 | 172.xx.xxx.xxx | 2882 | CO_STACK | CoStack | 198 | 102187008 | 101996928 |
| 1004 | 172.xx.xxx.xxx | 2882 | CO_STACK | KvstorCacheMb | 0 | 0 | 0 |
| 1004 | 172.xx.xxx.xxx | 2882 | DEFAULT_CTX_ID | ApplySrv | 1 | 409600 | 401408 |
| 1004 | 172.xx.xxx.xxx | 2882 | DEFAULT_CTX_ID | APPLY_STATUS | 1 | 8128 | 7936 |
| 1004 | 172.xx.xxx.xxx | 2882 | DEFAULT_CTX_ID | ArcFetchQueue | 1 | 8540160 | 8519680 |
| 1004 | 172.xx.xxx.xxx | 2882 | DEFAULT_CTX_ID | ArcSenderQueue | 1 | 933888 | 931072 |
| 1004 | 172.xx.xxx.xxx | 2882 | DEFAULT_CTX_ID | AsyncFreezeTabl | 1 | 114688 | 111096 |
| 1004 | 172.xx.xxx.xxx | 2882 | DEFAULT_CTX_ID | Autoincrement | 1 | 40960 | 37032 |
| 1004 | 172.xx.xxx.xxx | 2882 | DEFAULT_CTX_ID | Backup | 1 | 16384 | 12344 |
| 1004 | 172.xx.xxx.xxx | 2882 | DEFAULT_CTX_ID | BackupIOPerMgr | 1 | 1152 | 960 |
+-----------+----------------+----------+-------------------------------+-----------------+--------+-----------+-----------+
10 rows in set
