Description
This view displays the statistics of each SQL request on all OBServer nodes, including the source and execution status. The view is tenant-based. Except for the sys tenant, 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 that is monotonically increasing in a single machine |
| TRACE_ID | varchar(128) | NO | Trace ID of the statement |
| SID | bigint(20) unsigned | NO | Session connection ID |
| 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 |
| QUERY_SQL | longtext | NO | 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 scenarios |
| DFO_ID | bigint(20) | NO | ID of the current subplan in parallel execution scenarios |
| SQC_ID | bigint(20) | NO | ID of the local coordinator in parallel execution scenarios |
| WORKER_ID | bigint(20) | NO | ID of the worker thread in parallel execution scenarios |
| 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 | 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 status of the wait event. |
| WAIT_TIME_MICRO | bigint(20) | NO | The time for which the wait event is waiting, in microseconds. |
| TOTAL_WAIT_TIME_MICRO | bigint(20) | NO | The total time for all waits 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 receiving the request to the end of the execution, 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 waiting time of the request in the queue, in microseconds. |
| DECODE_TIME | bigint(20) | NO | The time for decoding after the request is dequeued, 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 for plan execution, in microseconds. |
| APPLICATION_WAIT_TIME | bigint(20) unsigned | NO | The total time for all application events, in microseconds. |
| CONCURRENCY_WAIT_TIME | bigint(20) unsigned | NO | The total time for all concurrency events, in microseconds. |
| USER_IO_WAIT_TIME | bigint(20) unsigned | NO | The total time for all user I/O events, in microseconds. |
| SCHEDULE_TIME | bigint(20) unsigned | NO | The total time for all schedule events, in microseconds. |
| ROW_CACHE_HIT | bigint(20) | NO | The number of hits in the row cache. |
| BLOOM_FILTER_CACHE_HIT | bigint(20) | NO | The number of hits in the Bloom filter cache. |
| BLOCK_CACHE_HIT | bigint(20) | NO | The number of hits in the block cache. |
| 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 | The number of rows scanned in one direction. |
| PUSHDOWN_STORAGE_FILTER_ROW_CNT | bigint(20) | NO | The number of rows filtered by the storage filter 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 for the request. |
| USED_WORKER_COUNT | bigint(20) | NO | The actual number of worker threads used for the request. |
| SCHED_INFO | varchar(16384) | YES | The scheduling information of 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 | The Prepare ID corresponding to the request:
|
| PS_INNER_STMT_ID | bigint(20) | NO | The Prepare ID corresponding to the request:
|
| TX_ID | bigint(20) | NO | The hash value of the transaction corresponding to the request. |
| SNAPSHOT_VERSION | bigint(20)unsigned | NO | The snapshot read version number of the current statement. |
| REQUEST_TYPE | bigint(20) | NO | The type of the request: |
| IS_BATCHED_MULTI_STMT | tinyint(4) | NO | Indicates whether the Batch Multi Stmt 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 during PS execution. |
| RULE_NAME | varchar(256) | NO | The name of the rule. |
| PARTITION_HIT | tinyint(4) | NO |
|
| TX_INTERNAL_ROUTING | bigint(20) | NO | Indicates whether the SQL statement is internally routed:
|
| TX_STATE_VERSION | bigint(20) unsigned | NO | The transaction state version of the SQL statement. |
| FLT_TRACE_ID | varchar(1024) | NO | The trace ID of the full-link trace for 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 | The trace ID of the outer PL of the current SQL statement. If no outer PL exists, this value is NULL.
Note
|
| PLSQL_EXEC_TIME | bigint(20) | NO | The time spent on PL execution (excluding SQL execution time), in microseconds
Note
|
| FORMAT_SQL_ID | varchar(32) | NO | The 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 | The 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 displayed only in the thread that shows the 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 displayed only in the thread that shows the query_text.
Note
|
| PROXY_USER | varchar(128) | YES |
Note
|
| PLSQL_COMPILE_TIME | bigint(20) | NO | The time spent on PL/SQL compilation.
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 status of the transaction.
Note |
| TX_TABLE_READ_CNT | bigint(20) | YES | The number of times that the transaction status table is queried.
NoteThis field was introduced in V4.5.0 of the V4.5.x series. |
| OUTROW_LOB_CNT | bigint(20) | YES | The number of outrow LOB columns read during the query.
NoteThis field was introduced in V4.5.0 of the V4.5.x series. |
| COMMIT_TIME | bigint(20) | NO | The time spent on the commit operation. If the SQL statement does not trigger a commit, the default value is 0.
NoteThis field was introduced in V4.6.0 of the V4.6.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 of this view:

Overview of common SQL statements
SQL routing information
The SQL plan types in OceanBase Database are categorized into the following four types:
Local plan: The transaction session and the leader of the partition involved in the statement are on the same OBServer node. It can involve multiple partitions, but multiple partitions cannot exist in the same table.
Remote plan: The transaction session and the leader of the partition involved in the statement are on different OBServer nodes. It can involve multiple partitions, but multiple partitions cannot exist in the same table.
Distribute plan: The statement involves multiple partitions. The partitions can be distributed across one or more OBServer nodes.
Uncertain plan: The number of partitions involved in the statement cannot be determined during the execution of the statement. This type of plan 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 whether the proportion of the above plans meets their expectations. Here is an example of a statement for statistics of SQL plans:
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 indicate Local plans, Remote plans, Distribute plans, and Uncertain plans, respectively.
Slow SQL statistics
Query the SQL statements that take longer than a specified threshold within a specific time period and optimize the SQL plans 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 whether the transaction model for business stress testing meets your expectations, such as single-SQL transactions 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 statements executed in the same session
You can query all business requests based on the session ID (SID). This is mainly used for business model analysis.
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;
