V$SESSION_LONGOPS displays the status of various operations that run for longer than 6 seconds (in absolute time). These operations currently include many backup and recovery functions, statistics gathering, and query execution, and more operations are added for every Oracle release.
V$SESSION_LONGOPS is still used as a dynamic performance view in Oracle 19c. It remains a valuable tool for monitoring the progress of long-running operations within the database.
What is V$SESSION_LONGOPS?
`V$SESSION_LONGOPS` is a dynamic performance view that provides details about operations that run for a long time, such as:
- Full Table Scans
- Parallel Queries
- Hash Joins
- Index Builds
- RMAN Backup and Recovery
- Sorting and Table Moves
Is It Still Relevant in Oracle 19c?
Yes, it continues to be "actively maintained" and provides real-time insights into session progress. It is particularly useful in
Enterprise Manager (OEM) Performance Hub and SQL Monitoring to track "session activities and execution status".
How to Use It in Oracle 19c
-
Checking Long-Running Operations
SELECT SID, SERIAL#, OPNAME, TOTALWORK, SOFAR,
(SOFAR/TOTALWORK)*100 AS PERCENT_COMPLETE, TIME_REMAINING, ELAPSED_SECONDS
FROM V$SESSION_LONGOPS
WHERE SOFAR <> TOTALWORK;
SOFAR <> TOTALWORK
ensures you see only active operations.
PERCENT_COMPLETE
helps track progress.
-
Monitoring Specific SQL Queries
SELECT SID, SERIAL#, SQL_ID, OPNAME, ELAPSED_SECONDS, TIME_REMAINING
FROM V$SESSION_LONGOPS
WHERE SQL_ID = 'your_sql_id_here';
- Helps track the progress of a specific SQL statement.
-
Identifying Long-Running RMAN Jobs
SELECT SID, SERIAL#, OPNAME, MESSAGE, TIME_REMAINING, ELAPSED_SECONDS
FROM V$SESSION_LONGOPS
WHERE OPNAME LIKE 'RMAN%';
- Useful for monitoring RMAN backup and restore operations.
When Does V$SESSION_LONGOPS Update?
- Only certain long-running operations appear in this view.
- The update frequency depends on Oracle’s internal execution tracking.
- Some short transactions or operations with low execution time may not appear.
Alternative Monitoring Options in Oracle 19c
-
V$SESSION - To monitor active sessions and SQL execution:
-
SELECT SID, SERIAL#, STATUS, SQL_ID, EVENT, SECONDS_IN_WAIT
FROM V$SESSION
WHERE STATUS = 'ACTIVE';
-
V$SQL_MONITOR - For real-time SQL execution details:
-
SELECT SQL_ID, STATUS, ELAPSED_TIME, CPU_TIME, QUEUE_DURATION
FROM V$SQL_MONITOR;
-
DBA_HIST_ACTIVE_SESS_HISTORY (ASH Analytics)
- Provides historical performance insights.
Conclusion
`V$SESSION_LONGOPS` is still used in Oracle 19c for tracking long-running operations. However, for more real-time insights, tools like V$SQL_MONITOR and ASH Analytics are also recommended.
There are a number of dynamic tables in the Oracle data dictionary and these tables are updated while the database is running. All these tables begin with the prefix
V$
. In Oracle, there is a new dynamic table for monitoring some long-running operations, such as backup and recovery operations. This table is called
V$ SESSION_LONGOPS
. The table includes columns such as:
- UNITS: The unit of measurement for the work
- TOTALWORK: The total number of work units estimated for the job
- SOFAR: The number of work units completed so far
- LASTUPDATETIME: The last time the table was updated
- ELAPSEDTIME: The total time elapsed since the operation began
This view displays the status of various operations that run for longer than 6 seconds (in absolute time). These operations currently include many backup and recovery functions, statistics gathering, and query execution, and more operations are added for every Oracle release. To monitor query execution progress, you must be using the cost-based optimizer and you must:
- Set the TIMED_STATISTICS or SQL_TRACE parameter to true
- Gather statistics for your objects with the ANALYZE statement or the DBMS_STATS package
You can add information to this view about application-specific long-running operations by using the DBMS_APPLICATION_INFO.SET_SESSION_LONGOPS procedure.
Column |
Datatype |
Description |
SID |
NUMBER |
Session identifier |
SERIAL# |
NUMBER |
Session serial number |
OPNAME |
VARCHAR2(64) |
Brief description of the operation |
TARGET |
VARCHAR2(64) |
The object on which the operation is carried out |
TARGET_DESC |
VARCHAR2(32) |
Description of the target |
SOFAR |
NUMBER |
The units of work done so far |
TOTALWORK |
NUMBER |
The total units of work |
UNITS |
VARCHAR2(32) |
The units of measurement |
START_TIME |
DATE |
The starting time of operation |
LAST_UPDATE_TIME |
DATE |
Time when statistics last updated |
TIMESTAMP |
DATE |
Timestamp |
TIME_REMAINING |
NUMBER |
Estimate (in seconds) of time remaining for the operation to complete |
ELAPSED_SECONDS |
NUMBER |
The number of elapsed seconds from the start of operations |
CONTEXT |
NUMBER |
Context |
MESSAGE |
VARCHAR2(512) |
Statistics summary message |
USERNAME |
VARCHAR2(30) |
User ID of the user performing the operation |
SQL_ADDRESS |
RAW(4 | 8) |
Used with the value of the SQL_HASH_VALUE column to identify the SQL statement associated with the operation |
SQL_HASH_VALUE |
NUMBER |
Used with the value of the SQL_ADDRESS column to identify the SQL statement associated with the operation |
SQL_ID |
VARCHAR2(13) |
SQL identifier of the SQL statement associated with the operation |
QCSID |
NUMBER |
Session identifier of the parallel coordinator |