Note
This view is introduced in OceanBase Database V4.0.0.
Purpose
The V$OB_SQL_AUDIT view displays the statistics such as the source and execution status of each SQL request on the current OBServer node. 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 |
| 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 | The port number of the client that sends the request. |
| TENANT_ID | bigint(20) | NO | The ID of the tenant that sends the request. |
| TENANT_NAME | varchar(64) | NO | The name of the tenant that sends the request. |
| 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) | NO | 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 ID of the database. |
| DB_NAME | varchar(128) | NO | The name of the database. |
| SQL_ID | varchar(32) | NO | The ID of the SQL statement
Note
|
| QUERY_SQL | longtext | NO | The actual SQL statement. |
| 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 a parallel execution scenario. |
| DFO_ID | bigint(20) | NO | The ID of the current sub-plan in a parallel execution scenario. |
| SQC_ID | bigint(20) | NO | The ID of the local coordinator in a parallel execution scenario. |
| WORKER_ID | bigint(20) | NO | The ID of the worker thread in a parallel execution scenario. |
| EVENT | varchar(64) | NO | The name of the longest waiting event. |
| P1TEXT | varchar(64) | NO | Parameter 1 of the waiting event. |
| P1 | bigint(20) unsigned | NO | The value of parameter 1 of the waiting event. |
| P2TEXT | varchar(64) | NO | Parameter 2 of the waiting event. |
| P2 | bigint(20) unsigned | NO | The value of parameter 2 of the waiting event. |
| P3TEXT | varchar(64) | NO | Parameter 3 of the waiting event. |
| P3 | bigint(20) unsigned | NO | The value of parameter 3 of the waiting event. |
| LEVEL | bigint(20) | NO | The level of the waiting event. |
| WAIT_CLASS_ID | bigint(20) | NO | The class ID 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 waiting event. |
| WAIT_TIME_MICRO | bigint(20) | NO | The time waited for the waiting event, in microseconds. |
| TOTAL_WAIT_TIME_MICRO | bigint(20) | NO | The total time of all waits during execution, in microseconds. |
| TOTAL_WAITS | bigint(20) | NO | The total number of waits during execution. |
| RPC_COUNT | bigint(20) | NO | The number of RPCs sent. |
| PLAN_TYPE | bigint(20) | NO | The execution plan type: |
| 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 cache is hit. |
| REQUEST_TIME | bigint(20) | NO | The start execution time, in microseconds. |
| ELAPSED_TIME | bigint(20) | NO | The total time from when the request is received to when it is executed, in microseconds. |
| NET_TIME | bigint(20) | NO | The time from when the RPC is sent to when the request is received, in microseconds. |
| NET_WAIT_TIME | bigint(20) | NO | The time from when the request is received to when it enters the queue, in microseconds. |
| QUEUE_TIME | bigint(20) | NO | The time the request waits in the queue, in microseconds. |
| DECODE_TIME | bigint(20) | NO | The time after the request is dequeued for decoding, in microseconds. |
| GET_PLAN_TIME | bigint(20) | NO | The time from when the request is processed to when the plan is obtained, in microseconds. |
| EXECUTE_TIME | bigint(20) | NO | The time taken for plan execution, in microseconds. |
| APPLICATION_WAIT_TIME | bigint(20) unsigned | NO | The total time of all Application class events, in microseconds. |
| CONCURRENCY_WAIT_TIME | bigint(20) unsigned | NO | The total time of all Concurrency class events, in microseconds. |
| USER_IO_WAIT_TIME | bigint(20) unsigned | NO | The total time of all user_io class events, in microseconds. |
| SCHEDULE_TIME | bigint(20) unsigned | NO | The time of all Schedule class events, in microseconds. |
| ROW_CACHE_HIT | bigint(20) | NO | The number of row cache hits. |
| BLOOM_FILTER_CACHE_HIT | bigint(20) | NO | The number of Bloom Filter cache hits. |
| BLOCK_CACHE_HIT | bigint(20) | NO | The number of block cache hits. |
| DISK_READS | bigint(20) | NO | The number of physical reads. |
| RETRY_CNT | bigint(20) | NO | The number of retries. |
| TABLE_SCAN | tinyint(4) | NO | Indicates whether the request contains a full table scan. |
| CONSISTENCY_LEVEL | bigint(20) | NO | The consistency level. Valid values:
|
| MEMSTORE_READ_ROW_COUNT | bigint(20) | NO | The number of rows read from MemStore. |
| SSSTORE_READ_ROW_COUNT | bigint(20) | NO | The number of rows read from SSStore. |
| DATA_BLOCK_READ_CNT | bigint(20) | NO | The number of data microblocks accessed. |
| DATA_BLOCK_CACHE_HIT | bigint(20) | NO | The number of data microblock cache hits. |
| INDEX_BLOCK_READ_CNT | bigint(20) | NO | The number of intermediate-layer microblocks accessed. |
| INDEX_BLOCK_CACHE_HIT | bigint(20) | NO | The number of intermediate-layer microblock cache hits. |
| BLOCKSCAN_BLOCK_CNT | bigint(20) | NO | The number of data microblocks scanned on one side. |
| BLOCKSCAN_ROW_CNT | bigint(20) | NO | The number of data rows scanned on one side. |
| PUSHDOWN_STORAGE_FILTER_ROW_CNT | bigint(20) | NO | The number of rows after the storage filter is pushed down. |
| REQUEST_MEMORY_USED | bigint(20) | NO | The memory consumed by the request. |
| EXPECTED_WORKER_COUNT | bigint(20) | NO | The expected number of worker threads. |
| USED_WORKER_COUNT | bigint(20) | NO | The actual number of worker threads used. |
| SCHED_INFO | varchar(16384) | NO | The scheduling information of the request. |
| FUSE_ROW_CACHE_HIT | bigint(20) | NO | This field is not supported. The field is NULL by default. |
| PS_CLIENT_STMT_ID | bigint(20) | NO | The prepare ID of the request:
|
| PS_INNER_STMT_ID | bigint(20) | NO | The prepare ID of the request:
|
| TX_ID | bigint(20) | NO | The transaction ID of 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 the batch multi-statement optimization is performed. |
| OB_TRACE_INFO | varchar(4096) | NO | The trace information specified 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 during data reading, in microseconds. |
| PARAMS_VALUE | longtext | NO | The parameter values bound to the PS protocol. |
| RULE_NAME | varchar(256) | NO | The name of the rule.
NoteThis field is introduced in OceanBase Database V4.1.0. |
| PARTITION_HIT | tinyint(4) | NO |
NoteThis field is introduced in OceanBase Database V4.1.0. |
| TX_INTERNAL_ROUTING | bigint(20) | NO | Indicates whether the SQL statement is internally routed:
NoteThis field is introduced in OceanBase Database V4.1.0. |
| TX_STATE_VERSION | bigint(20) unsigned | NO | The transaction state version of the SQL statement.
NoteThis field is introduced in OceanBase Database V4.1.0. |
| FLT_TRACE_ID | varchar(1024) | NO | The trace ID for end-to-end tracing. If this field is empty, the statement is not end-to-end traced. This field is a UUID, which is different from a trace ID. The format is similar to: 000600d6-a5de-038c-6c80-df07e4e79149
NoteThis field is introduced in OceanBase Database V4.2.1. |
| PL_TRACE_ID | varchar(128) | NO | The trace ID of the outer PL statement. If no outer PL statement exists, this field is NULL.
Note
|
| PLSQL_EXEC_TIME | bigint(20) | NO | The time taken for PL execution (excluding SQL execution time), in microseconds.
Note
|
| TOTAL_MEMSTORE_READ_ROW_COUNT | bigint(20) | NO | The total number of rows read from MemStore during the entire operation. This variable is displayed only in the thread that displays query_text.
Note
|
| TOTAL_SSSTORE_READ_ROW_COUNT | bigint(20) | NO | The total number of rows read from SSStore during the entire operation. This variable is displayed only in the thread that displays query_text.
Note
|
| PROXY_USER | varchar(128) | NO |
Note
|
| SEQ_NUM | bigint(20) | NO | The statement sequence number in the transaction.
Note
|
| NETWORK_WAIT_TIME | bigint(20) unsigned | NO | The total time of all Network class events, in microseconds.
Note
|
| PLSQL_COMPILE_TIME | bigint(20) | NO | The PL compilation time.
Note
|
| INSERT_DUPLICATE_ROW_COUNT | bigint(20) | NO | The number of duplicate rows in the insertup or replace into statement.
Note
|
Sample query
Query the statistics such as the source and execution status of each SQL request on the current OBServer node.
obclient [oceanbase]> SELECT * FROM oceanbase.V$OB_SQL_AUDIT LIMIT 1\G
The query result is as follows:
*************************** 1. row ***************************
SVR_IP: xx.xx.xx.xx
SVR_PORT: 2882
REQUEST_ID: 30801920
SQL_EXEC_ID: 93882142
TRACE_ID: YB42AC1E87E9-0006XXXXXXXXX-0-0
SID: 3221606733
CLIENT_IP: 0.0.0.0
CLIENT_PORT: 0
TENANT_ID: 1
TENANT_NAME: sys
EFFECTIVE_TENANT_ID: 1
USER_ID: 200001
USER_NAME: root
USER_GROUP: 0
USER_CLIENT_IP: 0.0.0.0
DB_ID: 201001
DB_NAME: oceanbase
SQL_ID: CF2AADDE69A639BC676C2E9E772A1AF0
QUERY_SQL: SELECT zone FROM __all_server where svr_ip='172.xx.xxx.xxx' and svr_port=2882
PLAN_ID: 15914
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: exec inner sql wait
P1TEXT: wait inner sql class
P1: 0
P2TEXT: inner session id
P2: 4611686018499745791
P3TEXT:
P3: 0
LEVEL: 0
WAIT_CLASS_ID: 100
WAIT_CLASS#: 0
WAIT_CLASS: OTHER
STATE: WAITED SHORT TIME
WAIT_TIME_MICRO: 68
TOTAL_WAIT_TIME_MICRO: 68
TOTAL_WAITS: 1
RPC_COUNT: 0
PLAN_TYPE: 1
IS_INNER_SQL: 1
IS_EXECUTOR_RPC: 0
IS_HIT_PLAN: 1
REQUEST_TIME: 1745729987475292
ELAPSED_TIME: 166
NET_TIME: 0
NET_WAIT_TIME: 0
QUEUE_TIME: 0
DECODE_TIME: 0
GET_PLAN_TIME: 97
EXECUTE_TIME: 69
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: 73728
EXPECTED_WORKER_COUNT: 0
USED_WORKER_COUNT: 0
SCHED_INFO: NULL
FUSE_ROW_CACHE_HIT: 1
PS_CLIENT_STMT_ID: -1
PS_INNER_STMT_ID: -1
TX_ID: 0
SNAPSHOT_VERSION: 1745729987292962000
REQUEST_TYPE: 1
IS_BATCHED_MULTI_STMT: 0
OB_TRACE_INFO: NULL
PLAN_HASH: 8470076267874576774
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:
STMT_TYPE: SELECT
TOTAL_MEMSTORE_READ_ROW_COUNT: 0
TOTAL_SSSTORE_READ_ROW_COUNT: 0
PROXY_USER:
SEQ_NUM: 1745729987474579
NETWORK_WAIT_TIME: 0
PLSQL_COMPILE_TIME: 0
INSERT_DUPLICATE_ROW_COUNT: 0