Unable To Find Failed SQL Execution From DBA_HIST_SQLSTAT
Last updated on JUNE 05, 2018
Applies to:Oracle Database - Enterprise Edition - Version 22.214.171.124 and later
Information in this document applies to any platform.
Unable to get failed SQL detail from dba_hist_sqlstat. How to get failed SQL detail?
Use V$SQL_MONITOR, as it displays SQL statements whose execution have been (or are being) monitored by Oracle. An entry is created in V$SQL_MONITOR every time the execution of a SQL statement is being monitored. SQL monitoring is automatically started when a SQL statement runs parallel or when it has consumed at least 5 seconds of CPU or I/O time.
When the SQL statement being monitored is executing, statistics in V$SQL_MONITOR are generally refreshed in near real time, once every second. Once the execution ends, monitoring information is not deleted immediately. Instead, it is kept in V$SQL_MONITOR for at least one minute. The entry will eventually be deleted to reclaim its space as new statements are monitored.
So, use V$SQL_MONITOR table and use below two columns:
ELAPSED_TIME --- Elapsed time (in microseconds); updated as the statement executes
STATUS SQL execution status:
EXECUTING - SQL statement is still executing
DONE (ERROR) - Execution terminated with an error
DONE (FIRST N ROWS) - Execution terminated by the application before all rows were fetched
DONE (ALL ROWS) - Execution terminated and all rows were fetched
DONE - Execution terminated (parallel execution)
If query is cancelled, you may get the status as DONE (ERROR).
Entry on the table will not be there for long, so take the snapshot of the table for specific interval.
Sign In with your My Oracle Support account
Don't have a My Oracle Support account? Click to get started
My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms