Note
This view is available starting with V4.0.0.
Purpose
The GV$OB_SQL_AUDIT view displays the source, execution status, and other statistics for each SQL request on all OBServer nodes. This view is tenant-separated. Only the system tenant can query this view. Other tenants cannot query this view across tenants.
Columns
| Column | Type | Nullable | Description |
|---|---|---|---|
| SVR_IP | varchar(46) | NO | The IP address of the server. |
| SVR_PORT | bigint(20) | NO | The port number. |
| REQUEST_ID | bigint(20) | NO | The ID of the request. |
| SQL_EXEC_ID | bigint(20) | NO | The ID of the execution. |
| TRACE_ID | varchar(128) | NO | The trace ID of the statement. |
| SID | bigint(20) unsigned | NO | For V4.2.x:
|
| CLIENT_IP | varchar(46) | NO | |
| CLIENT_PORT | bigint(20) | NO | The port number of the client that sends the request. |
| TENANT_ID | bigint(20) | NO | The tenant ID.
NoteStarting from V4.2.3, this field indicates the same value as the |
| TENANT_NAME | varchar(64) | NO | The name of the tenant. |
| EFFECTIVE_TENANT_ID | bigint(20) | NO | The tenant ID. |
| USER_ID | bigint(20) | NO | The ID of the user that sends the request. |
| USER_NAME | varchar(64) | NO | The name of the user that sends the request. |
| USER_GROUP | bigint(20) | YES | The ID of the resource group to which the user belongs. |
| USER_CLIENT_IP | varchar(46) | NO | The IP address of the client that sends the request. |
| DB_ID | bigint(20) unsigned | NO | The database ID. |
| DB_NAME | varchar(128) | NO | The name of the database. |
| SQL_ID | varchar(32) | NO | The ID of the SQL statement.
NoteStarting from V4.2.3, for PL requests executed by using the CALL statement or anonymous blocks, this field displays the actual MD5 value. |
| QUERY_SQL | longtext | NO | The actual SQL statement.
NoteThis field is available starting with V4.2.5 BP2. It is only visible to the SYS tenant. |
| PLAN_ID | bigint(20) | NO | The ID of the execution plan. |
| AFFECTED_ROWS | bigint(20) | NO | The number of affected rows. |
| RETURN_ROWS | bigint(20) | NO | The number of returned rows. |
| PARTITION_CNT | bigint(20) | NO | The number of partitions involved in the request. |
| RET_CODE | bigint(20) | NO | The execution result return code: |
| QC_ID | bigint(20) unsigned | NO | The scheduler ID in parallel execution scenarios. |
| DFO_ID | bigint(20) | NO | The ID of the current subplan in parallel execution scenarios. |
| SQC_ID | bigint(20) | NO | The ID of the local coordinator in parallel execution scenarios. |
| WORKER_ID | bigint(20) | NO | The ID of the worker thread in parallel execution scenarios. |
| EVENT | varchar(64) | NO | The name of the longest waiting event. |
| P1TEXT | varchar(64) | NO | The first parameter of the waiting event. |
| P1 | bigint(20) unsigned | NO | The value of the first parameter of the waiting event. |
| P2TEXT | varchar(64) | NO | The second parameter of the waiting event. |
| P2 | bigint(20) unsigned | NO | The value of the second parameter of the waiting event. |
| P3TEXT | varchar(60) | NO | The third parameter of the waiting event. |
| P3 | bigint(20) unsigned | NO | The value of the third parameter of the waiting event. |
| LEVEL | bigint(20) | NO | The level of the waiting event. |
| WAIT_CLASS_ID | bigint(20) | NO | The ID of the class to which the waiting event belongs. |
| WAIT_CLASS# | bigint(20) | NO | The index of the class to which the waiting event belongs. |
| WAIT_CLASS | varchar(64) | NO | The name of the class to which the waiting event belongs. |
| STATE | varchar(19) | NO | The state of the event. |
| WAIT_TIME_MICRO | bigint(20) | NO | The time waited for the event, in microseconds. |
| TOTAL_WAIT_TIME_MICRO | bigint(20) | NO | The total wait time for all events, in microseconds. |
| TOTAL_WAITS | bigint(20) | NO | The total number of waits for all events. |
| RPC_COUNT | bigint(20) | NO | The number of RPC requests. |
| PLAN_TYPE | bigint(20) | NO | The execution plan type. Valid values: |
| IS_INNER_SQL | tinyint(4) | NO | Indicates whether the event is an internal SQL statement. |
| IS_EXECUTOR_RPC | tinyint(4) | NO | Indicates whether the event is an RPC. |
| IS_HIT_PLAN | tinyint(4) | NO | Indicates whether the plan_cache cache hit occurred. |
| REQUEST_TIME | bigint(20) | NO | The start execution time, in microseconds. |
| ELAPSED_TIME | bigint(20) | NO | The total time consumed from receiving the request to execution completion, in microseconds. |
| NET_TIME | bigint(20) | NO | The time from sending the RPC to receiving the request, in microseconds. |
| NET_WAIT_TIME | bigint(20) | NO | The time from receiving the request to entering the queue, in microseconds. |
| QUEUE_TIME | bigint(20) | NO | The wait time for the request in the queue, in microseconds. |
| DECODE_TIME | bigint(20) | NO | The decode time after dequeuing, in microseconds. |
| GET_PLAN_TIME | bigint(20) | NO | The time from the start of the process to obtaining the plan, in microseconds. |
| EXECUTE_TIME | bigint(20) | NO | The time consumed by the execution of the plan, in microseconds. |
| APPLICATION_WAIT_TIME | bigint(20) unsigned | NO | The total time of all Application events, in microseconds. |
| CONCURRENCY_WAIT_TIME | bigint(20) unsigned | NO | The total time of all Concurrency events, in microseconds. |
| USER_IO_WAIT_TIME | bigint(20) unsigned | NO | The total time of all user io events, in microseconds. |
| SCHEDULE_TIME | bigint(20) unsigned | NO | The time of all Schedule events, in microseconds. |
| ROW_CACHE_HIT | bigint(20) | NO | The number of times the row cache is hit. |
| BLOOM_FILTER_CACHE_HIT | bigint(20) | NO | Bloom Filter cache hit count |
| BLOCK_CACHE_HIT | bigint(20) | NO | Block cache hit count |
| DISK_READS | bigint(20) | NO | Physical read count |
| RETRY_CNT | bigint(20) | NO | Retry count |
| 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 microblocks that hit the cache. |
| INDEX_BLOCK_READ_CNT | bigint(20) | NO | Number of intermediate microblocks accessed. |
| INDEX_BLOCK_CACHE_HIT | bigint(20) | NO | Number of intermediate microblocks that hit the cache. |
| BLOCKSCAN_BLOCK_CNT | bigint(20) | NO | Number of data microblocks scanned in one direction. |
| BLOCKSCAN_ROW_CNT | bigint(20) | NO | Number of data rows scanned in one direction. |
| PUSHDOWN_STORAGE_FILTER_ROW_CNT | bigint(20) | NO | Number of rows filtered by the pushed-down storage filter. |
| REQUEST_MEMORY_USED | bigint(20) | NO | Memory consumed by the request. |
| EXPECTED_WORKER_COUNT | bigint(20) | NO | Expected number of worker threads for the request. |
| USED_WORKER_COUNT | bigint(20) | NO | Actual number of worker threads used by the request. |
| SCHED_INFO | varchar(16384) | YES | Scheduling information for the request. |
| FUSE_ROW_CACHE_HIT | bigint(20) | NO | This column is not supported. The default value is NULL. |
| PS_CLIENT_STMT_ID | bigint(20) | NUMBER(38) | The ID of the client Prepare statement corresponding to the request:
|
| PS_INNER_STMT_ID | bigint(20) | NUMBER(38) | This field records the internal (database internal) Prepare ID corresponding to the request:
|
| TX_ID | bigint(20) | NO | The transaction ID corresponding to the request. |
| SNAPSHOT_VERSION | bigint(20) | NO | The read snapshot version used by the SQL statement. |
| REQUEST_TYPE | bigint(20) | NO | The 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 | The trace information set by the user. |
| PLAN_HASH | bigint(20) unsigned | NO | The hash value of the execution plan. |
| LOCK_FOR_READ_TIME | bigint(20) | NO | The time spent waiting for a lock when reading data, in microseconds. |
| PARAMS_VALUE | longtext | NO | The parameter values bound to the PS. |
| RULE_NAME | varchar(256) | NO | The name of the rule.
NoteThis field is available starting with V4.1.0. |
| PARTITION_HIT | tinyint(4) | NO |
NoteThis field is available starting with V4.1.0. |
| TX_INTERNAL_ROUTING | bigint(20) | NO | Indicates whether transaction routing is enabled for the current transaction:
Note
|
| TX_STATE_VERSION | bigint(20) unsigned | NO | When transaction routing is enabled, the version number increments if the transaction state changes after executing the statement; otherwise, it remains unchanged.
Note
|
| FLT_TRACE_ID | varchar(1024) | NO | The trace_id for full-link tracing of this record. If this field is empty, it indicates that the record is not monitored by full-link tracing. This field is a UUID, different from the trace. Its format is similar to: 000600d6-a5de-038c-6c80-df07e4e79149
NoteThis field is available starting with V4.2.1. |
| PL_TRACE_ID | varchar(128) | NO | The trace ID of the outer PL for the current SQL statement (NULL if there is no outer PL).
NoteThis field is available starting with V4.2.2. |
| PLSQL_EXEC_TIME | bigint(20) | NO | The time spent executing the PL, excluding SQL execution time, in microseconds.
NoteThis field is available starting with V4.2.2. |
| FORMAT_SQL_ID | varchar(32) | NO | The MD5 value generated by the Format SQL text for this record.
NoteThis field is available starting with V4.2.3. |
| NETWORK_WAIT_TIME | bigint(20) unsigned | YES | The total time for all network events, in microseconds.
NoteThis field is available starting with V4.2.3. |
| STMT_TYPE | varchar(128) | YES | Type |
| TOTAL_MEMSTORE_READ_ROW_COUNT | bigint(20) | NO | The total number of rows read from MemStore during the entire job (displayed only in the thread that shows the query text).
NoteThis view is available starting with V4.2.3. |
| TOTAL_SSSTORE_READ_ROW_COUNT | bigint(20) | NO | The total number of rows read from the SSSTORE in the query process. (This variable is displayed only in the query thread.)
NoteThis view is available starting with V4.2.3. |
| PROXY_USER | varchar(128) | YES |
NoteThis column is available starting with V4.2.3. |
| SEQ_NUM | bigint(20) | NO | The statement sequence number in the transaction.
NoteThis column is available starting from V4.2.5. Its default value is NULL. |
| PLSQL_COMPILE_TIME | bigint(20) | NO | The PL compilation time.
NoteThis column is available starting with V4.2.5 BP2. By default, the value is NULL. |
| USER_CLIENT_PORT | bigint(20) | NO | This column displays the client port number.
NoteThis column was introduced in V4.2.5 BP2. This column has a default value of NULL. |
| TRANS_STATUS | varchar(256) | NO | Specifies the transaction status. Valid values: ON, OFF, IMPLICIT, and OFF.
NoteThis column was introduced in V4.2.5 BP2. The default value is NULL. |
Sample query
Query the source, execution status, and other statistics 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: 589824
SQL_EXEC_ID: -1
TRACE_ID: YB42AC1E87E4-00062A8B77EAC58D-0-0
SID: 3221530618
CLIENT_IP: 0.0.0.0
CLIENT_PORT: 0
TENANT_ID: 1
TENANT_NAME:
EFFECTIVE_TENANT_ID: 1
USER_ID: 200001
USER_NAME:
USER_GROUP: 0
USER_CLIENT_IP: 0.0.0.0
DB_ID: 201001
DB_NAME:
SQL_ID: D41D8CD98F00B204E9800998ECF8427E
QUERY_SQL:
PLAN_ID: 2350
AFFECTED_ROWS: 0
RETURN_ROWS: 0
PARTITION_CNT: 0
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: 1
IS_HIT_PLAN: 1
REQUEST_TIME: 1735633628762154
ELAPSED_TIME: 1388
NET_TIME: 73
NET_WAIT_TIME: 10
QUEUE_TIME: 78
DECODE_TIME: 1213
GET_PLAN_TIME: 0
EXECUTE_TIME: 58
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: 0
CONSISTENCY_LEVEL: 3
MEMSTORE_READ_ROW_COUNT: 0
SSSTORE_READ_ROW_COUNT: 0
DATA_BLOCK_READ_CNT: 0
DATA_BLOCK_CACHE_HIT: 0
INDEX_BLOCK_READ_CNT: 0
INDEX_BLOCK_CACHE_HIT: 0
BLOCKSCAN_BLOCK_CNT: 0
BLOCKSCAN_ROW_CNT: 0
PUSHDOWN_STORAGE_FILTER_ROW_CNT: 0
REQUEST_MEMORY_USED: 0
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: 1735633628672808000
REQUEST_TYPE: 3
IS_BATCHED_MULTI_STMT: 0
OB_TRACE_INFO: NULL
PLAN_HASH: 0
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:
NETWORK_WAIT_TIME: 0
STMT_TYPE: SELECT
TOTAL_MEMSTORE_READ_ROW_COUNT: 0
TOTAL_SSSTORE_READ_ROW_COUNT: 0
PROXY_USER:
SEQ_NUM: 1
PLSQL_COMPILE_TIME: 0
USER_CLIENT_PORT: 0
TRANS_STATUS: Transaction not opened
1 row in set (0.011 sec)