DISPLAY_ACTIVE_SESSION_PLAN

2026-02-02 07:28:28  Updated

The DISPLAY_ACTIVE_SESSION_PLAN function is used to display the real-time plan details of a specified session.

Applicability

This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only MySQL mode.

Function definition

DBMS_XPLAN.DISPLAY_ACTIVE_SESSION_PLAN(
           session_id   INTEGER DEFAULT 0,
           format       VARCHAR2  DEFAULT  'TYPICAL',
           svr_ip       VARCHAR2  DEFAULT  NULL,      -- default value: server connected by client
           svr_port     INTEGER DEFAULT 0           -- default value: server connected by client
           )
return DISPLAY_ACTIVE_SESSION_PLAN;

Parameters

Parameter Description
session_id The session ID of the user. This is the session ID of the server, not the proxy session ID.
format The plan format. Valid values:
  • 'BASIC': displays minimal information, such as the operator ID, operator name, operator remarks, and expression.
  • 'TYPICAL': displays basic information, such as the operator ID, operator name, operator remarks, optimizer-estimated output rows, optimizer-estimated execution time, and expression. If the plan has been executed, it also displays the actual feedback information of the first execution, such as the actual number of rows and cost.
  • 'ALL': displays comprehensive information, such as the operator ID, operator name, operator remarks, optimizer-estimated output rows, optimizer-estimated execution time, and expression. It also displays the effective hints, query block name trace, outline, base table optimization, constant parameterization, constraints, and plan notes.
  • 'ADVANCED': displays comprehensive information, such as the operator ID, operator name, operator remarks, optimizer-estimated output rows, optimizer-estimated execution time, and expression. It also displays the tree structure information of complex plans.
svr_ip The IP address of the node where the plan is located. The default value is the IP address of the node to which the session is connected.
svr_port The port number of the node where the plan is located. The default value is the port number of the node to which the session is connected.

Examples

/* Execute a slow SQL statement */
obclient> SELECT COUNT(*) FROM TABLE(GENERATOR(100000)) A, TABLE(GENERATOR(10000))B;   
+------------+
| COUNT(*)   |
+------------+
| 1000000000 |
+------------+
1 row in set

/* Connect to another session and use the SHOW PROCESSLIST command to query the session ID of the executing SQL statement. */
obclient> SHOW PROCESSLIST;
+------------+------+--------------------+------+---------+------+--------+---------------------------------------------------------------------------+
| ID         | USER | HOST               | DB   | COMMAND | TIME | STATE  | INFO                                                                      |
+------------+------+--------------------+------+---------+------+--------+---------------------------------------------------------------------------+
| 3221675847 | SYS  | 11.x.x.44:57841 | SYS  | Query   |    0 | ACTIVE | show processlist                                                          |
| 3221668463 | SYS  | 11.x.x.44:57530 | SYS  | Query   |    2 | ACTIVE | select count(*) from table(generator(100000)) A, table(generator(10000))B |
+------------+------+--------------------+------+---------+------+--------+---------------------------------------------------------------------------+

/* Display the session plan details. */
obclient> SELECT * FROM TABLE (DBMS_XPLAN.DISPLAY_ACTIVE_SESSION_PLAN(3221668463));
+--------------------------------------------------------------------------------------------------------------------+
| COLUMN_VALUE                                                                                                       |
+--------------------------------------------------------------------------------------------------------------------+
| ==============================================================================================================     |
| |ID|OPERATOR                     |NAME|EST.ROWS|EST.TIME(us)|REAL.ROWS|REAL.TIME(us)|IO TIME(us)|CPU TIME(us)|     |
| --------------------------------------------------------------------------------------------------------------     |
| |0 |SCALAR GROUP BY              |    |1       |1794        |0        |0            |0          |0           |     |
| |1 |└─NESTED-LOOP JOIN CARTESIAN |    |39601   |1076        |0        |0            |0          |0           |     |
| |2 |  ├─FUNCTION_TABLE           |A   |199     |1           |0        |0            |0          |0           |     |
| |3 |  └─MATERIAL                 |    |199     |80          |0        |0            |0          |0           |     |
| |4 |    └─FUNCTION_TABLE         |B   |199     |1           |0        |0            |0          |0           |     |
| ==============================================================================================================     |
| Outputs & filters:                                                                                                 |
| -------------------------------------                                                                              |
|   0 - output([T_FUN_COUNT(*)]), filter(nil), rowset=256                                                            |
|       group(nil), agg_func([T_FUN_COUNT(*)])                                                                       |
|   1 - output(nil), filter(nil), rowset=256                                                                         |
|       conds(nil), nl_params_(nil), use_batch=false                                                                 |
|   2 - output(nil), filter(nil)                                                                                     |
|       value(GENERATOR(cast(:0, BIGINT(-1, 0))))                                                                    |
|   3 - output(nil), filter(nil), rowset=256                                                                         |
|   4 - output(nil), filter(nil)                                                                                     |
|       value(GENERATOR(cast(:1, BIGINT(-1, 0))))                                                                    |
+--------------------------------------------------------------------------------------------------------------------+

Contact Us