DB Version:11.2.0.4
OS : Oracle Linux 6.5
When I join gv$session and gv$sqlarea , should I use SQL_ID or SQL_ADDRESS as the join condition ? ie. Which is correct ; Query1 or Query2 ?
Query1:
SELECT count(*)
FROM gv$session a INNER JOIN gv$sqlarea b on A.sql_id = B.SQL_ID
WHERE a.inst_id = b.inst_id
and a.status = 'ACTIVE' AND a.TYPE = 'USER' AND a.username IS NOT NULL
ORDER BY sql_exec_start ASC
Query2:
SELECT count(*)
FROM gv$session a INNER JOIN gv$sqlarea b on a.sql_address=b.address
where a.inst_id = b.inst_id
and a.status = 'ACTIVE' AND a.TYPE = 'USER' AND a.username IS NOT NULL
ORDER BY sql_exec_start ASC