Unable To Find Failed SQL Execution From DBA_HIST_SQLSTAT
(Doc ID 2405540.1)
Last updated on NOVEMBER 04, 2019
Applies to:Oracle Database - Enterprise Edition - Version 188.8.131.52 and later
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A 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.
To view full details, sign in with your My Oracle Support account.
Don't have a My Oracle Support account? Click to get started!
In this Document