Description
This view displays the source, execution status, and other statistics of each SQL request on all OBServer nodes. The view is tenant-based. Only the system tenant can query this view. Other tenants cannot query this view across tenants.
Field description
| Field name | Type | NULL | 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, which is a monotonic increment ID for each execution. |
| TRACE_ID | varchar(128) | NO | The trace ID of the statement. |
| SID | bigint(20) unsigned | NO | Session ID |
| 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 ID of the tenant. |
| 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 | Database ID |
| DB_NAME | varchar(128) | NO | Database name |
| SQL_ID | varchar(32) | NO | The ID of the SQL statement. |
| 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 return code of the execution result: |
| 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 value of parameter 1 of the waiting event. |
| P1 | bigint(20) unsigned | NO | The value of parameter 1 of the waiting event. |
| P2TEXT | varchar(64) | NO | The value of parameter 2 of the waiting event. |
| P2 | bigint(20) unsigned | NO | The value of parameter 2 of the waiting event. |
| P3TEXT | varchar(64) | NO | The value of 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 ID of the class to which the wait event belongs. |
| WAIT_CLASS# | bigint(20) | NO | The index of the class to which the wait event belongs. |
| WAIT_CLASS | varchar(64) | NO | The name of the class to which the wait event belongs. |
| STATE | varchar(19) | NO | The state of the wait event. |
| WAIT_TIME_MICRO | bigint(20) | NO | The time that the wait event waits for, in microseconds. |
| TOTAL_WAIT_TIME_MICRO | bigint(20) | NO | The total wait time during the execution, in microseconds. |
| TOTAL_WAITS | bigint(20) | NO | The total number of waits during the execution. |
| RPC_COUNT | bigint(20) | NO | The number of RPCs sent. |
| PLAN_TYPE | bigint(20) | NO | The 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 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 time of the execution, in microseconds. |
| ELAPSED_TIME | bigint(20) | NO | The total time consumed from when the request is received to when the execution is completed, 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 that the request waits in the queue, in microseconds. |
| DECODE_TIME | bigint(20) | NO | The time for decoding after the request leaves the queue, in microseconds. |
| GET_PLAN_TIME | bigint(20) | NO | The time from when the process starts to when the plan is obtained, in microseconds. |
| EXECUTE_TIME | bigint(20) | NO | The time consumed for executing 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 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 the MemStore. |
| SSSTORE_READ_ROW_COUNT | bigint(20) | NO | The number of rows read from the 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 microblocks hit in the cache. |
| INDEX_BLOCK_READ_CNT | bigint(20) | NO | The number of intermediate microblocks accessed. |
| INDEX_BLOCK_CACHE_HIT | bigint(20) | NO | The number of intermediate microblocks hit in the cache. |
| BLOCKSCAN_BLOCK_CNT | bigint(20) | NO | The number of data microblocks scanned in one direction. |
| BLOCKSCAN_ROW_CNT | bigint(20) | NO | Number of rows scanned by one-side scan. |
| PUSHDOWN_STORAGE_FILTER_ROW_CNT | bigint(20) | NO | Number of rows filtered after the storage filter is pushed down. |
| REQUEST_MEMORY_USED | bigint(20) | NO | Memory consumed by the request. |
| EXPECTED_WORKER_COUNT | bigint(20) | NO | Number of worker threads expected for the request. |
| USED_WORKER_COUNT | bigint(20) | NO | Number of worker threads actually used for the request. |
| SCHED_INFO | varchar(16384) | YES | Scheduling information for the request. |
| FUSE_ROW_CACHE_HIT | bigint(20) | NO | This field is not supported. The default value is NULL. |
| PS_CLIENT_STMT_ID | bigint(20) | NO | Prepare ID corresponding to the request:
|
| PS_INNER_STMT_ID | bigint(20) | NO | Prepare ID corresponding to the request:
|
| TX_ID | bigint(20) | NO | Hash value of the transaction corresponding to the request. |
| SNAPSHOT_VERSION | bigint(20)unsigned | NO | Snapshot read version number of the current statement. |
| REQUEST_TYPE | bigint(20) | NO | Type of the request: |
| IS_BATCHED_MULTI_STMT | tinyint(4) | NO | Whether to optimize Batch Multi Stmt. |
| OB_TRACE_INFO | varchar(4096) | NO | Trace information set by the user. |
| PLAN_HASH | bigint(20) unsigned | NO | Hash value of the execution plan. |
| LOCK_FOR_READ_TIME | bigint(20) | NO | Time consumed waiting for a lock when reading data, in microseconds. |
| PARAMS_VALUE | longtext | NO | Parameter values during PS execution. |
| RULE_NAME | varchar(256) | NO | Rule name |
| PARTITION_HIT | tinyint(4) | NO |
|
| TX_INTERNAL_ROUTING | bigint(20) | NO | Indicates whether the SQL statement has been internally routed:
|
| TX_STATE_VERSION | bigint(20) unsigned | NO | Transaction state version of the SQL statement. |
| FLT_TRACE_ID | varchar(1024) | NO | Trace ID for the full-link trace of the record. If this field is empty, it indicates that the record is not monitored by the full-link trace. This field is a UUID, which is different from the trace. Its format is similar to: 000600d6-a5de-038c-6c80-df07e4e79149
Note
|
| PL_TRACE_ID | varchar(128) | NO | Trace ID of the outer PL for the current SQL statement. If no outer PL exists, this field is NULL.
Note
|
| PLSQL_EXEC_TIME | bigint(20) | NO | Time consumed by PL execution (excluding SQL execution time), in microseconds
Note
|
| FORMAT_SQL_ID | varchar(32) | NO | MD5 value generated by the Format SQL text for the record. |
| STMT_TYPE | varchar(128) | YES | The DML type is returned as needed:
|
| NETWORK_WAIT_TIME | bigint(20) unsigned | YES | Total time of all Network events, in microseconds. |
| TOTAL_MEMSTORE_READ_ROW_COUNT | bigint(20) | NO | The total number of rows read from the MEMSTORE during the entire process. This variable is only displayed in threads that show query_text.
Note
|
| TOTAL_SSSTORE_READ_ROW_COUNT | bigint(20) | NO | The total number of rows read from the SSSTORE during the entire process. This variable is only displayed in threads that show query_text.
Note
|
| PROXY_USER | varchar(128) | YES |
Note
|
| PLSQL_COMPILE_TIME | bigint(20) | NO | The PL compilation time.
Note
|
| INSERT_DUPLICATE_ROW_COUNT | bigint(20) | YES | The number of duplicate rows when the insertup or replace into statement is executed.
Note |
| USER_CLIENT_PORT | bigint(20) | NO | The client port number.
Note
|
| TRANS_STATUS | varchar(256) | NO | The transaction status. This field indicates whether the transaction is explicitly started, implicitly started, or not started.
Note |
| TX_TABLE_READ_CNT | bigint(20) | YES | The number of times the transaction status table is queried.
NoteThis field was introduced in V4.4.2 BP1 of the V4.4.x series. |
| OUTROW_LOB_CNT | bigint(20) | YES | The number of outrow LOB columns read during the query.
NoteThis field was introduced in V4.4.2 BP1 of the V4.4.x series. |
| COMMIT_TIME | bigint(20) | NO | The commit time of an SQL statement that triggers a commit in a transaction. If an SQL statement does not trigger a commit, the default value is 0.
NoteThis field was introduced in V4.4.2 BP1 of the V4.4.x series. |
Important event intervals
The following figure shows the relationships between the important events in the ELAPSED_TIME, REQUEST_TIME, NET_WAIT_TIME, QUEUE_TIME, DECODE_TIME, GET_PLAN_TIME, EXECUTE_TIME, and COMMIT_TIME columns in this view:

Overview of SQL
SQL routing information
OceanBase Database SQL plans are categorized into four types:
Local plan: The transaction session and the leader of the partition involved in the statement are on the same OBServer. It can involve multiple partitions, but not multiple partitions of the same table.
Remote plan: The transaction session and the leader of the partition involved in the statement are on different OBServers. It can involve multiple partitions, but not multiple partitions of the same table.
Distribute plan: The current statement involves multiple partitions. Partitions can be distributed across one or more OBServers.
Uncertain plan: The number of partitions cannot be determined during statement execution. This typically occurs in scenarios such as global indexes and foreign keys.
Single-machine transactions are more efficient than cross-machine transactions. Therefore, users need to verify if the proportion of the above plans meets expectations. Here is an example of SQL plan statistics:
select plan_type, count(1) from GV$OB_SQL_AUDIT where tenant_id = *** and request_time > time_to_usec('2021-10-08 12:00:00') group by plan_type;
The plan_type field can take the values 1, 2, 3, and 4, which correspond to Local, Remote, Distribute, and Uncertain plans, respectively.
Slow SQL statistics
Query for SQL statements that take longer than a specified threshold within a given time period and optimize the SQL plan based on the query results:
select tenant_id, elapsed_time, usec_to_time(request_time), substr(query_sql, 1, 50) from GV$OB_SQL_AUDIT where tenant_id=1001 and elapsed_time > 100000 and request_time > time_to_usec('2021-10-08 12:00:00') order by elapsed_time desc limit 40;
SQL statistics within a transaction
Each SQL statement in the sql_audit table is expected to record the unique transaction identifier: transaction_hash. You can use this field to find all SQL statements within the current transaction and determine if the transaction model meets expectations, such as single-SQL or multi-SQL transactions.
select tenant_id, substr(query_sql,1,50) from GV$OB_SQL_AUDIT where tenant_id=1002 and TX_ID='***' order by request_time;
SQL executed in the same session
You can query all business requests based on the SID. This is mainly used for analyzing business models.
select tenant_id, substr(query_sql,1,50) from GV$OB_SQL_AUDIT where tenant_id=1002 and sid=1001 and request_time > time_to_usec('2021-10-08 12:00:00') order by request_time;
