Check the Execution plan from SQL ID of SQL Query in Oracle
Get the SQL ID for the SQL Statement
-- First you need to execute the SQL statement to get the SQL ID from v$sql view.
Select sql_id from v$sql where sql_text like 'SELECT * FROM EMP';
SQL_ID
-------------
4ttqgu8uu8fus
Get the explain plain or execution plan for the SQL ID in Oracle
set line 200 pages 200
SELECT * FROM TABLE (DBMS_XPLAN.DISPLAY_CURSOR ('&sqlid'));
---Explain Plan
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------
SQL_ID 4ttqgu8uu8fus, child number 0
-------------------------------------
SELECT * FROM EMP
Plan hash value: 3956160932
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 165K(100)| |
| 1 | TABLE ACCESS FULL| EMP | 38M| 2522M| 165K (1)| 00:00:07 |
--------------------------------------------------------------------------