In some scenarios, unbalanced loads between OBServer nodes may occur, causing performance bottlenecks. To diagnose such issues, you can query the SQL traffic distribution and the queries per second (QPS) on the OBServer nodes.
The following example queries the execution status of a specific SQL statement on each node within the past second:
SELECT
/*+ PARALLEL(15) */ -- Specifies the use of 15 parallel execution (PX) threads to speed up queries
t2.zone, -- The zone where the OBServer node is located
t1.svr_ip, -- The IP address of the OBServer node where the SQL statement is processed
COUNT(*) AS RPC_COUNT, -- The number of remote procedure call (RPC) requests executed on each OBServer node
AVG(t1.elapsed_time) AS AVG_ELAPSED_TIME, -- The average execution time of the SQL statement on each OBServer node
AVG(t1.queue_time) AS AVG_QUEUE_TIME -- The average wait time of the SQL statement in the queue on each OBServer node
FROM
oceanbase.GV$OB_SQL_AUDIT t1, -- A system view that provides SQL audit information
__all_server t2 -- A system table that contains information about all OBServer nodes
WHERE
t1.svr_ip = t2.svr_ip -- Ensures the JOIN condition is used to match SQL audit records with server information
AND t1.tenant_id = 1001 -- Specifies the tenant ID for the query
AND t1.sql_id = 'BF7AA13A28DF50BA5C33FF19F1DBD8A9' -- Specifies the ID of the target SQL statement
AND t1.is_executor_rpc = 0 -- The filter conditions that ensure only non-executor RPC requests are included in the query results
AND t1.request_time > (time_to_usec(now()) - 1000000) -- Limits the query time range to the last second
AND t1.request_time < time_to_usec(now()) -- Ensures the request time falls within the one-second window, with the current time as the reference time
GROUP BY
t1.svr_ip; -- Groups the results by the IP address of the OBServer node