Monday, January 31, 2011

How to get XPLAIN PLAN for a SQL query

set lines 200
set pages 10000

delete plan_table where statement_id = 'MY_XPLAN'

/* INSERT BINDS HERE */
variable b1 number
variable b2 varchar2(100)

explain plan set statement_id = 'MY_XPLAN'
for
/* Replace the next statement with the statement you
want to explain
*/
select sal
from emp
where ename = :b2
/

set feedback off
select *
from table(dbms_xplan.display(null, 'MY_XPLAN'));
set feedback on



set lines 200
set pages 10000

EXPLAIN PLAN SET STATEMENT_ID = 'A9'
FOR
SELECT PPP.partner_id
,PPP.partner_party_id
,PPP.partner_level
,PAT.description
FROM apps.pv_partner_profiles PPP
,PV_ATTRIBUTE_CODES_TL PAT
WHERE PPP.partner_level = PAT.ATTR_CODE_ID
AND PAT.language = userenv('LANG')
AND PPP.partner_id = 3716072;

SELECT * FROM TABLE(DBMS_XPLAN.display(null, 'A9'));


Method 2
---------

EXPLAIN PLAN FOR
SELECT * FROM table_name WHERE where_clause;


SET LINESIZE 120
SET PAGESIZE 0

SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);

1 comment:

GAMESH TAWADE said...

Awesome product I bought for my parents and they aver really very happy.
Visit this next page