The TOP_DYNAMIC_SQL administrative view returns the top dynamic SQL statements sortable by number of executions, average execution time, number of sorts, or sorts per statement. These are the queries that should get focus to ensure they are well tuned.
The schema is SYSIBMADM.
SELECT NUM_EXECUTIONS, AVERAGE_EXECUTION_TIME_S, STMT_SORTS,
SORTS_PER_EXECUTION, SUBSTR(STMT_TEXT,1,60) AS STMT_TEXT
FROM SYSIBMADM.TOP_DYNAMIC_SQL
ORDER BY NUM_EXECUTIONS DESC FETCH FIRST 5 ROWS ONLY
NUM_EXECUTIONS AVERAGE_EXECUTION_TIME_S STMT_SORTS ...
-------------------- ------------------------ -------------------- ...
148 0 0 ...
123 0 0 ...
2 0 0 ...
1 0 0 ...
1 0 0 ...
5 record(s) selected.
... SORTS_PER_EXECUTION ...
... -------------------- ...
... 0 ...
... 0 ...
... 0 ...
... 0 ...
... 0 ...
... STMT_TEXT
... ------------------------------------------------------------
... SELECT A.ID, B.EMPNO, B.FIRSTNME, B.LASTNAME, A.DEPT FROM E
... SELECT A.EMPNO, A.FIRSTNME, A.LASTNAME, B.LOCATION, B.MGRNO
... SELECT A.EMPNO, A.FIRSTNME, A.LASTNAME, B.DEPTNAME FROM EMP
... SELECT ATM.SCHEMA, ATM.NAME, ATM.CREATE_TIME, ATM.LAST_WAIT,
... SELECT * FROM JESSICAE.EMP_RESUME
Column name | Data type | Description or corresponding monitor element |
---|---|---|
SNAPSHOT_TIMESTAMP | TIMESTAMP | snapshot_timestamp - Snapshot timestamp monitor element |
NUM_EXECUTIONS | BIGINT | num_executions - Statement executions |
AVERAGE_EXECUTION_TIME_S | BIGINT | Average execution time, in seconds. |
STMT_SORTS | BIGINT | stmt_sorts - Statement sorts |
SORTS_PER_EXECUTION | BIGINT | Number of sorts per statement execution. |
STMT_TEXT | CLOB(2 M) | stmt_text - SQL statement text |
DBPARTITIONNUM | SMALLINT | The database partition from which the data was retrieved for this row. |