I'm playing around with the data from GV$SQL_MONITOR
and I found something that I don't understand. The oracle documentation says that SQL_EXEC_START
, SQL_ID
, and SQL_EXEC_ID
combine to "uniquely identify one execution of the SQL statement". However, I see the below data in the table. Many records have the same SQL_EXEC_START
, SQL_ID
, and SQL_EXEC_ID
, but a unique SID.
Does anyone here have insight into why the documentation and my observations contradict each other?
Possibly relevant: I observed that all of these queries finish at the same time.
SQL_EXEC_START SQL_ID SID SQL_EXEC_ID ELAPSED_TIME STATUS LAST_REFRESH_TIME
--------------------- ------------- --- ----------- ------------ ------------------- ---------------------
2017-09-20 14:27:56 gncss37ygprra 196 16777218 1847766 EXECUTING 2017-09-20 14:27:58
2017-09-20 14:27:56 gncss37ygprra 3148 16777218 498598 EXECUTING 2017-09-20 14:28:00
2017-09-20 14:27:56 gncss37ygprra 3329 16777218 96863 EXECUTING 2017-09-20 14:28:00
2017-09-20 14:27:56 gncss37ygprra 480 16777218 1849199 EXECUTING 2017-09-20 14:27:58
2017-09-20 14:27:56 gncss37ygprra 3727 16777218 1848618 EXECUTING 2017-09-20 14:27:58
2017-09-20 14:27:56 gncss37ygprra 498 16777218 513823 EXECUTING 2017-09-20 14:28:00
2017-09-20 14:27:56 gncss37ygprra 2578 16777218 1955707 EXECUTING 2017-09-20 14:28:00
2017-09-20 14:27:56 gncss37ygprra 3541 16777218 1848522 EXECUTING 2017-09-20 14:27:58
Best Answer
Let's create the below function so we can have a long running parallel query and have time to query SQL monitoring data:
Then this table:
And:
And start this query:
If you query
GV$SQL_MONITOR
, with some additional columns, you can see it is a parallel query, and the sessions it's spawned, and also find the session that originally started it (QCSID):