Note
This view is available starting with V4.0.0.
Purpose
The GV$OB_SQL_AUDIT view displays statistics such as the source and execution status of each SQL request on all OBServer nodes. This view is tenant-specific. You can query this view only in the sys tenant.
Columns
| Column | Type | Nullable | Description |
|---|---|---|---|
| SVR_IP | varchar(46) | NO | IP address |
| SVR_PORT | bigint(20) | NO | Port number |
| REQUEST_ID | bigint(20) | NO | Request ID. |
| SQL_EXEC_ID | bigint(20) | NO | Execution ID of the current statement. |
| TRACE_ID | varchar(128) | NO | trace_id of the statement. |
| SID | bigint(20) unsigned | NO | For OceanBase Database V4.3.x:
|
| CLIENT_IP | varchar(46) | NO | |
| CLIENT_PORT | bigint(20) | NO | Port number of the client that sends the request. |
| TENANT_ID | bigint(20) | NO | ID of the tenant that sends the request. |
| TENANT_NAME | varchar(64) | NO | Name of the tenant that sends the request. |
| EFFECTIVE_TENANT_ID | bigint(20) | NO | Tenant ID. |
| USER_ID | bigint(20) | NO | ID of the user that sends the request. |
| USER_NAME | varchar(64) | NO | Name of the user that sends the request. |
| USER_GROUP | bigint(20) | YES | ID of the resource group to which the user belongs. |
| USER_CLIENT_IP | varchar(46) | NO | IP address of the client that sends the request. |
| DB_ID | bigint(20) unsigned | NO | Database ID. |
| DB_NAME | varchar(128) | NO | Database name. |
| SQL_ID | varchar(32) | NO | ID of the SQL statement.
Note
|
| QUERY_SQL | longtext | NO | The actual SQL statement. |
| PLAN_ID | bigint(20) | NO | ID of the execution plan. |
| AFFECTED_ROWS | bigint(20) | NO | Number of affected rows. |
| RETURN_ROWS | bigint(20) | NO | Number of returned rows. |
| PARTITION_CNT | bigint(20) | NO | Number of partitions involved in the request. |
| RET_CODE | bigint(20) | NO | Execution result return code: |
| QC_ID | bigint(20) unsigned | NO | Scheduler ID in parallel execution mode. |
| DFO_ID | bigint(20) | NO | ID of the current subplan in parallel execution mode. |
| SQC_ID | bigint(20) | NO | ID of the local coordinator in parallel execution mode. |
| WORKER_ID | bigint(20) | NO | ID of the worker thread in parallel execution mode. |
| EVENT | varchar(64) | NO | Name of the longest waiting event. |
| P1TEXT | varchar(64) | NO | Parameter 1 of the waiting event. |
| P1 | bigint(20) unsigned | NO | Value of parameter 1 of the waiting event. |
| P2TEXT | varchar(64) | NO | Parameter 2 of the waiting event. |
| P2 | bigint(20) unsigned | NO | Value of parameter 2 of the waiting event. |
| P3TEXT | varchar(64) | NO | Parameter 3 of the waiting event. |
| P3 | bigint(20) unsigned | NO | Value of parameter 3 of the waiting event. |
| LEVEL | bigint(20) | NO | Level of the waiting event. |
| WAIT_CLASS_ID | bigint(20) | NO | ID of the class to which the waiting event belongs. |
| WAIT_CLASS# | bigint(20) | NO | Index of the class to which the waiting event belongs. |
| WAIT_CLASS | varchar(64) | NO | Name of the class to which the waiting event belongs. |
| STATE | varchar(19) | NO | State of the waiting event. |
| WAIT_TIME_MICRO | bigint(20) | NO | Time spent waiting for the event, in microseconds. |
| TOTAL_WAIT_TIME_MICRO | bigint(20) | NO | Total time spent waiting for all events, in microseconds. |
| TOTAL_WAITS | bigint(20) | NO | Total number of waits. |
| RPC_COUNT | bigint(20) | NO | Number of RPCs sent. |
| PLAN_TYPE | bigint(20) | NO | Type of the execution plan: |
| IS_INNER_SQL | tinyint(4) | NO | Indicates whether the request is an internal SQL request. |
| IS_EXECUTOR_RPC | tinyint(4) | NO | Indicates whether the current request is an RPC request. |
| IS_HIT_PLAN | tinyint(4) | NO | Indicates whether the plan is hit in the plan cache. |
| REQUEST_TIME | bigint(20) | NO | Start time of the request, in microseconds. |
| ELAPSED_TIME | bigint(20) | NO | Total time consumed from receiving the request to executing it, in microseconds. |
| NET_TIME | bigint(20) | NO | Time from sending the RPC to receiving the request, in microseconds. |
| NET_WAIT_TIME | bigint(20) | NO | Time from receiving the request to entering the queue, in microseconds. |
| QUEUE_TIME | bigint(20) | NO | Time spent waiting in the queue, in microseconds. |
| DECODE_TIME | bigint(20) | NO | Time spent decoding after leaving the queue, in microseconds. |
| GET_PLAN_TIME | bigint(20) | NO | Time from starting to process to obtaining the plan, in microseconds. |
| EXECUTE_TIME | bigint(20) | NO | Time spent executing the plan, in microseconds. |
| APPLICATION_WAIT_TIME | bigint(20) unsigned | NO | Total time spent on all application events, in microseconds. |
| CONCURRENCY_WAIT_TIME | bigint(20) unsigned | NO | Total time spent on all concurrency events, in microseconds. |
| USER_IO_WAIT_TIME | bigint(20) unsigned | NO | Total time spent on all user_io events, in microseconds. |
| SCHEDULE_TIME | bigint(20) unsigned | NO | Time spent on all schedule events, in microseconds. |
| ROW_CACHE_HIT | bigint(20) | NO | Number of row cache hits. |
| BLOOM_FILTER_CACHE_HIT | bigint(20) | NO | Number of Bloom Filter cache hits. |
| BLOCK_CACHE_HIT | bigint(20) | NO | Number of block cache hits. |
| DISK_READS | bigint(20) | NO | Number of physical reads. |
| RETRY_CNT | bigint(20) | NO | Number of retries. |
| TABLE_SCAN | tinyint(4) | NO | Indicates whether the request contains a full-table scan. |
| CONSISTENCY_LEVEL | bigint(20) | NO | Consistency level. Valid values:
|
| MEMSTORE_READ_ROW_COUNT | bigint(20) | NO | Number of rows read from the MemStore. |
| SSSTORE_READ_ROW_COUNT | bigint(20) | NO | Number of rows read from the SSStore. |
| DATA_BLOCK_READ_CNT | bigint(20) | NO | Number of data microblocks accessed. |
| DATA_BLOCK_CACHE_HIT | bigint(20) | NO | Number of data microblock cache hits. |
| INDEX_BLOCK_READ_CNT | bigint(20) | NO | Number of intermediate-layer microblocks accessed. |
| INDEX_BLOCK_CACHE_HIT | bigint(20) | NO | Number of intermediate-layer microblock cache hits. |
| BLOCKSCAN_BLOCK_CNT | bigint(20) | NO | Number of data microblocks scanned on one side. |
| BLOCKSCAN_ROW_CNT | bigint(20) | NO | Number of data rows scanned on one side. |
| PUSHDOWN_STORAGE_FILTER_ROW_CNT | bigint(20) | NO | Number of rows after the storage filter is pushed down. |
| REQUEST_MEMORY_USED | bigint(20) | NO | Memory consumed by the request, in bytes. |
| EXPECTED_WORKER_COUNT | bigint(20) | NO | Expected number of worker threads. |
| USED_WORKER_COUNT | bigint(20) | NO | Number of worker threads actually used. |
| SCHED_INFO | varchar(16384) | YES | Scheduling information of the request. |
| FUSE_ROW_CACHE_HIT | bigint(20) | NO | This field is not supported. The field is set to NULL by default. |
| PS_CLIENT_STMT_ID | bigint(20) | NO | This field records the client Prepare ID of the request:
|
| PS_INNER_STMT_ID | bigint(20) | NO | This field records the internal (database-level) Prepare ID of the request:
|
| TX_ID | bigint(20) | NO | Transaction ID of the request. |
| SNAPSHOT_VERSION | bigint(20) | NO | Read snapshot version of the SQL statement. |
| REQUEST_TYPE | bigint(20) | NO | Type of the request: |
| IS_BATCHED_MULTI_STMT | tinyint(4) | NO | Indicates whether batch multi-statement optimization is performed. |
| OB_TRACE_INFO | varchar(4096) | NO | User-defined trace information. |
| PLAN_HASH | bigint(20) unsigned | NO | Hash value of the execution plan. |
| LOCK_FOR_READ_TIME | bigint(20) | NO | Time spent waiting for a lock during data reading, in microseconds. |
| PARAMS_VALUE | longtext | NO | Values of parameters bound to the PS statement. |
| RULE_NAME | varchar(256) | NO | Name of the rule.
NoteThis field is introduced in V4.1.0. |
| PARTITION_HIT | tinyint(4) | NO |
NoteThis field is introduced in V4.1.0. |
| TX_INTERNAL_ROUTING | bigint(20) | NO | Indicates whether the SQL statement is internally routed:
NoteThis field is introduced in V4.1.0. |
| TX_STATE_VERSION | bigint(20) unsigned | NO | Indicates the transaction state version of the SQL statement.
NoteThis field is introduced in V4.1.0. |
| FLT_TRACE_ID | varchar(1024) | NO | Indicates the trace ID of the full-link trace for the record. If this field is empty, the record is not monitored by the full-link trace. This field is a UUID, which is different from a trace. Its format is similar to: 000600d6-a5de-038c-6c80-df07e4e79149
NoteThis field is introduced in V4.2.1. |
| PL_TRACE_ID | varchar(128) | NO | Trace ID of the outer PL statement (NULL if no outer PL statement exists).
Note
|
| PLSQL_EXEC_TIME | bigint(20) | NO | Execution time of the PL statement (excluding SQL execution time), in microseconds.
Note
|
| FORMAT_SQL_ID | varchar(32) | NO | The MD5 value generated by formatting the SQL text of the record.
Note
|
| STMT_TYPE | varchar(128) | YES | The DML type is returned as needed:
Note
|
| TOTAL_MEMSTORE_READ_ROW_COUNT | bigint(20) | NO | Total number of rows read from the MemStore during the entire process (displayed only in the thread that displays the query text).
Note
|
| TOTAL_SSSTORE_READ_ROW_COUNT | bigint(20) | NO | Total number of rows read from the SSSTORE during the entire process (displayed only in the thread that displays the query text).
Note
|
| PROXY_USER | varchar(128) | NO |
Note
|
| SEQ_NUM | bigint(20) | NO | Statement sequence number in the transaction.
Note
|
| USER_CLIENT_PORT | bigint(20) | NO | Port number of the client.
NoteThis field is introduced in V4.3.5 BP4. The field is set to NULL by default. |
| TRANS_STATUS | varchar(256) | NO | Status of the transaction: NoteThis field is introduced in V4.3.5 BP4. The field is set to NULL by default. |
| NETWORK_WAIT_TIME | bigint(20) unsigned | NO | Total time spent on all network events, in microseconds.
Note
|
| PLSQL_COMPILE_TIME | bigint(20) | NO | PL compilation time.
Note
|
| INSERT_DUPLICATE_ROW_COUNT | bigint(20) | YES | Number of duplicate rows in insertup or replace into statements.
Note |
Sample query
Query the statistics such as the source and execution status of each SQL request on all OBServer nodes.
obclient [oceanbase]> SELECT * FROM oceanbase.GV$OB_SQL_AUDIT LIMIT 1\G
The query result is as follows:
*************************** 1. row ***************************
SVR_IP: 172.30.xxx.xxx
SVR_PORT: 2882
REQUEST_ID: 3187658
SQL_EXEC_ID: 32141215
TRACE_ID: YB42AC1E87EA-00063DDBE7EA56D3-0-0
SID: 3221593518
CLIENT_IP: 0.0.0.0
CLIENT_PORT: 0
TENANT_ID: 1002
TENANT_NAME: mysql001
EFFECTIVE_TENANT_ID: 1002
USER_ID: 200001
USER_NAME: root
USER_GROUP: 0
USER_CLIENT_IP: 0.0.0.0
DB_ID: 201001
DB_NAME: oceanbase
SQL_ID: C9B8EFE1B98D8F5BCEB705FC158DB450
QUERY_SQL:
PLAN_ID: 10252
AFFECTED_ROWS: 0
RETURN_ROWS: 1
PARTITION_CNT: 1
RET_CODE: 0
QC_ID: 0
DFO_ID: 0
SQC_ID: 0
WORKER_ID: 0
EVENT:
P1TEXT:
P1: 0
P2TEXT:
P2: 0
P3TEXT:
P3: 0
LEVEL: 0
WAIT_CLASS_ID: 100
WAIT_CLASS#: 0
WAIT_CLASS: OTHER
STATE: MAX_WAIT TIME ZERO
WAIT_TIME_MICRO: 0
TOTAL_WAIT_TIME_MICRO: 0
TOTAL_WAITS: 0
RPC_COUNT: 0
PLAN_TYPE: 1
IS_INNER_SQL: 1
IS_EXECUTOR_RPC: 0
IS_HIT_PLAN: 1
REQUEST_TIME: 1757065051303012
ELAPSED_TIME: 317
NET_TIME: 0
NET_WAIT_TIME: 0
QUEUE_TIME: 0
DECODE_TIME: 0
GET_PLAN_TIME: 160
EXECUTE_TIME: 157
APPLICATION_WAIT_TIME: 0
CONCURRENCY_WAIT_TIME: 0
USER_IO_WAIT_TIME: 0
SCHEDULE_TIME: 0
ROW_CACHE_HIT: 0
BLOOM_FILTER_CACHE_HIT: 0
BLOCK_CACHE_HIT: 0
DISK_READS: 0
RETRY_CNT: 0
TABLE_SCAN: 1
CONSISTENCY_LEVEL: 3
MEMSTORE_READ_ROW_COUNT: 0
SSSTORE_READ_ROW_COUNT: 1
DATA_BLOCK_READ_CNT: 0
DATA_BLOCK_CACHE_HIT: 1
INDEX_BLOCK_READ_CNT: 0
INDEX_BLOCK_CACHE_HIT: 1
BLOCKSCAN_BLOCK_CNT: 0
BLOCKSCAN_ROW_CNT: 0
PUSHDOWN_STORAGE_FILTER_ROW_CNT: 0
REQUEST_MEMORY_USED: 2237696
EXPECTED_WORKER_COUNT: 0
USED_WORKER_COUNT: 0
SCHED_INFO: NULL
FUSE_ROW_CACHE_HIT: 0
PS_CLIENT_STMT_ID: -1
PS_INNER_STMT_ID: -1
TX_ID: 0
SNAPSHOT_VERSION: 1757065051158230000
REQUEST_TYPE: 1
IS_BATCHED_MULTI_STMT: 0
OB_TRACE_INFO: NULL
PLAN_HASH: 190148091577278916
LOCK_FOR_READ_TIME: 0
PARAMS_VALUE:
RULE_NAME:
PARTITION_HIT: 1
TX_INTERNAL_ROUTING: 0
TX_STATE_VERSION: 0
FLT_TRACE_ID:
PL_TRACE_ID: NULL
PLSQL_EXEC_TIME: 0
FORMAT_SQL_ID: B1608FC1D8F04C855A6EAD99432EA7E0
STMT_TYPE: SELECT
TOTAL_MEMSTORE_READ_ROW_COUNT: 0
TOTAL_SSSTORE_READ_ROW_COUNT: 1
PROXY_USER:
SEQ_NUM: 1757065051293230
NETWORK_WAIT_TIME: 0
PLSQL_COMPILE_TIME: 0
INSERT_DUPLICATE_ROW_COUNT: 0
CCL_RULE_ID: 0
CCL_MATCH_TIME: 0
USER_CLIENT_PORT: 0
TRANS_STATUS: Transaction not opened
1 row in set (0.007 sec)