Sql Explain Plan
Hi Guys
I am new to SQL Tuning and i wanna know what exactly are the tables involved in finding the explain plan of sql's and what all the views that needs to be queried to find the explain lan of a query. Kindly help me .
Thanks
Ram
plan_table is used to get execution plan of any query. this table can be created with the script utlxplan.sql. You can find the script under ORACLE_HOME/rdbms/admin folder.
The process for getting the execution plan is
SQL> explain plan for
2 select * from emp where employee_id=12 ;
Explained.
SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'));
you can run the utlxpls.sql script also to get formated output and which can be found in ORACLE_HOME/rdbms/admin folder.
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost (%CPU) |
| 0 | SELECT STATEMENT | | 1 | 42 | 3 (0)|
|* 1 | TABLE ACCESS FULL | EMP | 1 | 42 | 3 (0)|
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
1 - filter("EMPLOYEE_ID"=12)
Similar Messages
-
Hi,
I was trying to get an explain plan for below query. (Refer - A)
BILL_DETAIL table have index of ZONECODE,MRNO,AREACODE,WCNO but still it's
showing 'TABLE ACCESS FULL in BILL_DETAIL'
If i select only first 4 column, it is going by index. (REFER - B)
As per my knowledge index will consider only where clause conditions
but here I couldn't understand why this considering select output columns.
First time I am trying sql explain plan statement, Please help me to correct
this query.
REFER - A
EXPLAIN PLAN FOR
SELECT B.ZONECODE ZONECODE, B.MRNO MRNO, B.AREACODE AREACODE, B.WCNO WCNO,
B.BILLNO BILLNO,B.BILLDT BILLDT,B.FROMDT FROMDT,B.TODT TODT,B.TOBEPAID TOBEPAID,
B.PREVUNPAID PREVUNPAID,B.DUEDT DUEDT
FROM BILL_DETAIL B, CONSUMER_MASTER C
WHERE B.ZONECODE = C.ZONECODE
AND B.MRNO = C.MRNO
AND B.AREACODE = C.AREACODE
AND B.WCNO = C.WCNO
AND UPPER(B.ZONECODE)=UPPER('SZ-4')
AND UPPER(B.MRNO)=UPPER('347')
AND UPPER(B.AREACODE)=UPPER('18')
AND UPPER(B.WCNO)=UPPER('30910')
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
| 0 | SELECT STATEMENT | | 1 | 71 | 9 (0)|
| 1 | NESTED LOOPS | | 1 | 71 | 9 (0)|
|* 2 | TABLE ACCESS FULL| BILL_DETAIL | 1 | 52 | 9 (0)|
|* 3 | INDEX UNIQUE SCAN| SYS_C008803 | 1 | 19 | 0 (0)|
Predicate Information (identified by operation id):
2 - filter(UPPER("B"."ZONECODE")='SZ-4' AND UPPER("B"."MRNO")='347'
AND UPPER("B"."AREACODE")='18' AND UPPER("B"."WCNO")='30910')
3 - access("B"."ZONECODE"="C"."ZONECODE" AND "B"."MRNO"="C"."MRNO"
AND "B"."AREACODE"="C"."AREACODE" AND "B"."WCNO"="C"."WCNO")
REFER - B
EXPLAIN PLAN FOR
SELECT B.ZONECODE ZONECODE, B.MRNO MRNO, B.AREACODE AREACODE, B.WCNO WCNO
FROM BILL_DETAIL B, CONSUMER_MASTER C
WHERE B.ZONECODE = C.ZONECODE
AND B.MRNO = C.MRNO
AND B.AREACODE = C.AREACODE
AND B.WCNO = C.WCNO
AND UPPER(B.ZONECODE)=UPPER('SZ-4')
AND UPPER(B.MRNO)=UPPER('347')
AND UPPER(B.AREACODE)=UPPER('18')
AND UPPER(B.WCNO)=UPPER('30910')
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
| 0 | SELECT STATEMENT | | 1 | 34 | 4 (0)|
| 1 | NESTED LOOPS | | 1 | 34 | 4 (0)|
|* 2 | INDEX FAST FULL SCAN| SYS_C008798 | 1 | 15 | 4 (0)|
|* 3 | INDEX UNIQUE SCAN | SYS_C008803 | 1 | 19 | 0 (0)|
Predicate Information (identified by operation id):
2 - filter(UPPER("B"."ZONECODE")='SZ-4' AND UPPER("B"."MRNO")='347'
AND UPPER("B"."AREACODE")='18' AND UPPER("B"."WCNO")='30910')
3 - access("B"."ZONECODE"="C"."ZONECODE" AND "B"."MRNO"="C"."MRNO"
AND "B"."AREACODE"="C"."AREACODE" AND "B"."WCNO"="C"."WCNO")
Note
- 'PLAN_TABLE' is old versionWelcome to the forums!
user13295080 wrote:
I was trying to get an explain plan for below query. (Refer - A)
BILL_DETAIL table have index of ZONECODE,MRNO,AREACODE,WCNO but still it's
showing 'TABLE ACCESS FULL in BILL_DETAIL'
If i select only first 4 column, it is going by index. (REFER - B)
As per my knowledge index will consider only where clause conditions
but here I couldn't understand why this considering select output columns.This is because Oracle is smart enough to know that the entire query can be satisfied by using the index without hitting the table. However, once you add a column that doesn't exist in the index Oracle has decided it is more efficient to use the full table scan.
I also noticed that all the row estimates are 1 in the execution plans. Is this expected? If not, have statistics on the relevant objects been gathered?
Generally speaking, when you have a query tuning question providing information in these threads is extremely helpful:
{message:id=1812597}
{thread:id=863295}
Additionally, when posting query plans, queries, or any code please use \ tags to preserve formatting.
Your code here!\ -
Tuning needed for sql:EXPLAIN PLAN attached
DB Version:10gR2
The below sql was running slow, so i took an explain plan
SQL> explain plan for
2 SELECT COUNT(1) FROM SHIP_DTL WHERE
3 SHIP_DTL.PLT_ID = 'AM834'
4 AND SHIP_DTL.WHSE = '34' AND
5 SHIP_DTL.STAT_CODE != '845'
6 ORDER BY SHIP_DTL.LOAD_SEQ ASC;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
| 0 | SELECT STATEMENT | | 1 | 18 | 5 (20)|
| 1 | SORT AGGREGATE | | 1 | 18 | |
|* 2 | TABLE ACCESS BY INDEX ROWID| SHIP_DTL | 200 | 3600 | 5 (20)|
|* 3 | INDEX RANGE SCAN | SHIP_DTL_IND_4 | 203 | | 3 (0)|
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
2 - filter("SHIP_DTL"."WHSE"='34' AND "SHIP_DTL"."STAT_CODE"<>845)
3 - access("SHIP_DTL"."PLT_ID"='AM834')Why is there an INDEX RANGE scan where there is no BETWEEN operator in the query? What are various options(indexes, rewriting query) in tuning this query?james_p wrote:
DB Version:10gR2
The below sql was running slow, so i took an explain planCheck your plan, the optimizer estimates that the following query:
select count(*)
from SHIP_DTL
where "SHIP_DTL"."PLT_ID"='AM834';only returns 200 records. Is this correct? Please post the result of above query.
It probably isn't the case, because retrieving 200 records per index range scan and single row random table access shouldn't take long, at maximum a couple of seconds if you need to read each block actually from disk rather than from the cache.
If the estimate is wrong you need to check the statistics on the table and index that were used by the optimizer to come to that conclusion.
Are you sure that this plan is the actual plan used at execution time? You can check for the actual plans used to execute by using the DBMS_XPLAN.DISPLAY_CURSOR function in 10g if the SQL is still cached in the Shared Pool. You need to pass the SQL_ID and SQL_CHILD_NUMBER which you can retrieve from V$SESSION while the statement is executing.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/ -
SQL Explain Plan tutorial links
Hello experts
I don't know anything about sql explain plan. I would like to learn it. I read several Oracle documents However I don't understand clearly. Do you know any article or powerpoint related to sql explain plan basics for beginners?
Thanks a lot for your help.944258 wrote:
Hello experts
I don't know anything about sql explain plan. I would like to learn it. I read several Oracle documents However I don't understand clearly. Do you know any article or powerpoint related to sql explain plan basics for beginners?
Thanks a lot for your help.http://www.lmgtfy.com/?q=oracle+explain+plan+tutorial -
Explain plan results are different in SQL Developer than SQL Plus
My Environment:
SQL Developer 1.0.0.15.27
Platform where SQL Developer is running: Windows XP 2002 SP2
Oracle Database and Client 9.2.0.7
Optimizer_mode: FIRST_ROWS
I have the following SQL statement:
SELECT a1.comp_id
FROM temp_au_company a0, au_company a1
WHERE :b2 = a0.temp_emp_code
AND a0.comp_id = a1.comp_id
AND a0.sls_terr_code != a1.sls_terr_code
AND a1.last_mdfy_date > :b1
When I run an Explain in SQL Developer I get the following access path (which is the one I really want):
SELECT STATEMENT TABLE ACCESS(BY INDEX ROWID) FEDLINK.AU_COMPANY NESTED LOOPS INDEX(RANGE SCAN)
FEDLINK.UX2_TEMP_AU_COMPANY
INDEX(RANGE SCAN) FEDLINK.PX1_COMPANY
However, when I execute the statement with sql_trace turned on and use tkprof to generate the actual access path, the statement executes as follows (which is WAY more expensive):
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 3.58 6.68 28136 29232 0 0
total 3 3.58 6.69 28136 29232 0 0
Misses in library cache during parse: 1
Optimizer goal: FIRST_ROWS
Parsing user id: 979 (FEDLINK) (recursive depth: 1)
Rows Row Source Operation
0 NESTED LOOPS
0 TABLE ACCESS FULL AU_COMPANY
0 INDEX RANGE SCAN UX2_TEMP_AU_COMPANY (object id 49783)
Notice the FULL access of au_company.
I understand that SQL Developer has nothing to do with why the statement executed the way it did, but why is the Explain in SQL Developer different than the actual execution plan?
Added note....when I run the explain in SQL Plus it is the same as the actual execution. Here is the explain from SQL Plus:
explain plan for SELECT a1.comp_id
FROM temp_au_company a0, au_company a1
WHERE '1' = a0.temp_emp_code
AND a0.comp_id = a1.comp_id
AND a0.sls_terr_code != a1.sls_terr_code
AND a1.last_mdfy_date > '01-MAY-2006';
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 2 | 76 | 2597 |
| 1 | NESTED LOOPS | | 2 | 76 | 2597 |
| 2 | TABLE ACCESS FULL | AU_COMPANY | 2 | 42 | 2595 |
| 3 | INDEX RANGE SCAN | UX2_TEMP_AU_COMPANY | 1 | 17 | 2
Thanks,
BrendaThe explain is different (full scan of au_company in SQL Plus / index access in SQL Developer) even when I use variables in SQL Plus. Here is the output for SQL Plus using variables instead of literals:
SQL> variable b1 varchar2
SQL> variable b2 char
SQL> explain plan for SELECT a1.comp_id
2 FROM temp_au_company a0, au_company a1
3 WHERE :b2 = a0.temp_emp_code
4 AND a0.comp_id = a1.comp_id
5 AND a0.sls_terr_code != a1.sls_terr_code
6 AND a1.last_mdfy_date > :b1
7 /
Explained.
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 3184 | 118K| 2995 |
| 1 | HASH JOIN | | 3184 | 118K| 2995 |
| 2 | INDEX RANGE SCAN | UX2_TEMP_AU_COMPANY | 3187 | 54179 | 3 |
| 3 | TABLE ACCESS FULL | AU_COMPANY | 24009 | 492K| 2983 |
Any other ideas? They should be the same.
Brenda -
Explain Plan in SQL Developer vs. SQLPlus
Hi everyone,
I've got a quick question. Why would an explain plan hang in SQL Developer but come back immediately in SQL Plus?
For example, in SQL developer, I write my statement and use the F6 command to bring up the explain plan and it just hangs and hangs. It looks like it's trying to generate an explain plan, but it's been running for hours now.
When I log into SQL Plus, I do a
SQL> explain plan for <query>:
SQL> select * from table(dbms_xplan.display);That whole process takes less than a minute to get the explain plan.
Is there something fundamentally different being executed by SQL Developer?
Thanks!
-JoeJoe,
F6 in SQL Developer runs an AutoTrace, which actually runs the SQL and also displays timings and the explain plan. If you only want the explain plan, use F10.
Regards,
Bob -
SQL Tuning- slow query on GL_BALANCES- Explain plan provided
Hi- I really need some help here.
The following SQL statement has been identified to perform poorly.
It currently takes from 2-3 minutes to execute. I see it is because GL_BALANCES has so many rows.
Is there any way around this? Explain and info below. Thanks gurus!
This is the SQL statement:
SELECT DISTINCT GLB.CODE_COMBINATION_ID CCID
FROM gl_balances GLB, gl_code_combinations GCC
WHERE GLB.ACTUAL_FLAG = 'A'
AND GLB.Last_Update_Date > to_date('11-JAN-2010','DD-MON-YYYY')
AND GLB.code_combination_id = GCC.code_combination_id
AND EXISTS (
SELECT 1
FROM fnd_flex_value_sets A, fnd_flex_values B
WHERE A.flex_value_set_name = 'XXX_XXX'
AND UPPER(B.ATTRIBUTE3) = 'APPORTIONMENT'
AND A.flex_value_set_id = b.flex_value_set_id
AND GCC.segment11 = b.flex_value
);The version of the database is 11.1.0.7.
These are the parameters relevant to the optimizer:
NAME TYPE VALUE
optimizerautostats_job boolean FALSE
optimizerextended_cursor_sharing_r string NONE
el
optimizer_capture_sql_plan_baselines boolean FALSE
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 11.1.0.7
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean FALSE
optimizer_use_invisible_indexes boolean FALSE
NAME TYPE VALUE
optimizer_use_pending_statistics boolean FALSE
optimizer_use_sql_plan_baselines boolean TRUE
SQL> show parameter db_file_multi
NAME TYPE VALUE
db_file_multiblock_read_count integer 128
SQL> show parameter db_block_size
NAME TYPE VALUE
db_block_size integer 8192
SQL> show parameter cursor_sharing
NAME TYPE VALUE
optimizerextended_cursor_sharing_r string NONE
el
cursor_sharing string EXACT
select
2 sname
3 , pname
4 , pval1
5 , pval2
6 from
7 sys.aux_stats$;
SNAME PNAME PVAL1
PVAL2
SYSSTATS_INFO STATUS
COMPLETED
SYSSTATS_INFO DSTART
09-02-2006 14:35
SYSSTATS_INFO DSTOP
09-02-2006 14:35
SNAME PNAME PVAL1
PVAL2
SYSSTATS_INFO FLAGS 1
SYSSTATS_MAIN CPUSPEEDNW 451.262136
SYSSTATS_MAIN IOSEEKTIM 10
SNAME PNAME PVAL1
PVAL2
SYSSTATS_MAIN IOTFRSPEED 4096
SYSSTATS_MAIN SREADTIM
SYSSTATS_MAIN MREADTIM
SNAME PNAME PVAL1
PVAL2
SYSSTATS_MAIN CPUSPEED
SYSSTATS_MAIN MBRC
SYSSTATS_MAIN MAXTHR
SNAME PNAME PVAL1
PVAL2
SYSSTATS_MAIN SLAVETHR
13 rows selected.
SQL> explain plan for
2 SELECT DISTINCT GLB.CODE_COMBINATION_ID CCID
3 FROM gl_balances GLB, gl_code_combinations GCC
4 WHERE GLB.code_combination_id = GCC.code_combination_id
5 AND GLB.ACTUAL_FLAG = 'A'
6 AND GLB.Last_Update_Date > '11-JAN-2010'
7 AND EXISTS (SELECT 1
8 FROM fnd_flex_value_sets A, fnd_flex_values B
9 WHERE A.flex_value_set_id = b.flex_value_set_id
10 AND A.flex_value_set_name = 'XXX_XXX'
11 AND UPPER(B.ATTRIBUTE3) = 'APPORTIONMENT'
12 AND GCC.segment11 = b.flex_value);
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 1839014065
| Id | Operation | Name | Rows | By
tes | Cost (%CPU)| Time |
PLAN_TABLE_OUTPUT
| 0 | SELECT STATEMENT | | 4102 |
296K| 955K (3)| 03:11:03 |
| 1 | HASH UNIQUE | | 4102 |
296K| 955K (3)| 03:11:03 |
|* 2 | HASH JOIN | | 4102 |
296K| 955K (3)| 03:11:03 |
| 3 | NESTED LOOPS | | |
| | |
PLAN_TABLE_OUTPUT
| 4 | NESTED LOOPS | | 23907 | 1
354K| 2598 (1)| 00:00:32 |
| 5 | NESTED LOOPS | | 1 |
45 | 5 (0)| 00:00:01 |
| 6 | TABLE ACCESS BY INDEX ROWID| FND_FLEX_VALUE_SETS | 1 |
28 | 2 (0)| 00:00:01 |
|* 7 | INDEX UNIQUE SCAN | FND_FLEX_VALUE_SETS_U2 | 1 |
PLAN_TABLE_OUTPUT
| 1 (0)| 00:00:01 |
|* 8 | TABLE ACCESS BY INDEX ROWID| FND_FLEX_VALUES | 1 |
17 | 3 (0)| 00:00:01 |
|* 9 | INDEX RANGE SCAN | FND_FLEX_VALUES_N2 | 53 |
| 1 (0)| 00:00:01 |
|* 10 | INDEX RANGE SCAN | GL_CODE_COMBINATIONS_N11 | 25427 |
| 106 (1)| 00:00:02 |
PLAN_TABLE_OUTPUT
| 11 | TABLE ACCESS BY INDEX ROWID | GL_CODE_COMBINATIONS | 18664 |
236K| 2593 (1)| 00:00:32 |
|* 12 | TABLE ACCESS FULL | GL_BALANCES | 1022K|
15M| 952K (3)| 03:10:32 |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
2 - access("GLB"."CODE_COMBINATION_ID"="GCC"."CODE_COMBINATION_ID")
7 - access("A"."FLEX_VALUE_SET_NAME"='SSA_SGL')
8 - filter(UPPER("B"."ATTRIBUTE3")='APPORTIONMENT')
9 - access("A"."FLEX_VALUE_SET_ID"="B"."FLEX_VALUE_SET_ID")
10 - access("GCC"."SEGMENT11"="B"."FLEX_VALUE")
12 - filter("GLB"."LAST_UPDATE_DATE">TO_DATE(' 2010-01-11 00:00:00', 'syyyy-mm
-dd hh24:mi:ss') AND
"GLB"."ACTUAL_FLAG"='A')
30 rows selected.As per the other replies, you've not really given enough information to go on - what are you trying to achieve, versions, etc.
On my old apps 11.5.8 system, the explain plan for your query uses GL_CODE_COMBINATIONS_U1 rather than a full scan of gl_code_combinations.
Check your stats are up to date (select table_name, num_rows, last_analyzed from dba_tables where ...)
See if you can also use period_name and/or period_set_name (or period_num) from GL_Periods rather than period_year (i.e. use P_YEAR to lookup the period_name/period_set_name/period_num from gl_periods). It might be faster to do per period and then consolidate for the whole year, as there are indexes on gl_balances for columns period_name, period_set_name, period_num.
regards, Ivan -
Not Understanding the filter in Explain Plan - filter(NULL IS NOT NULL)
Hi All,
Request your help in understanding the below scenario. (I am not aware of teh application and table details. Just trying to help my friend)
SQL> conn
Enter user-name: [email protected]
Enter password:
Connected.
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for Linux: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
--Checking the count in PO_LINES
SQL> select count(*) from po_lines;
COUNT(*)
0
--PO_LINES is a synonym
SQL> select object_type,owner from dba_objects where object_name = 'PO_LINES';
OBJECT_TYPE OWNER
SYNONYM APPS
--The synonym is pointing to PO.PO_LINES_ALL
SQL> select * from user_synonyms where synonym_name = 'PO_LINES';
SYNONYM_NAME TABLE_OWNER TABLE_NAME DB_LINK
PO_LINES PO PO_LINES_ALL
--But when counting PO.PO_LINES_ALL I am getting different result
SQL> select count(*) c from po.po_lines_all;
C
8828
--Explain plan of teh original query is
SQL> explain plan for
2 select
3 * from po_lines;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
| 0 | SELECT STATEMENT | | 1 | 252 | 0 (0)|
|* 1 | FILTER | | | | |
| 2 | TABLE ACCESS FULL| PO_LINES_ALL | 8796 | 2164K| 106 (4)|
Predicate Information (identified by operation id):
1 - filter(NULL IS NOT NULL)
--Now the object PO.PO_LINES_ALL is TABLE, not an mview.
SQL> select object_type,owner from dba_objects where object_name = 'PO_LINES_ALL';
OBJECT_TYPE OWNER
TABLE POSeek your help in understanding what is happening here.
Thanks in Advance,
jeneeshNext time, prefix with APPS. when you show us the explain plan:
SQL> explain plan for
2 select
3 * from apps.po_lines; -- added the prefix of owner.Just like you prefixed with PO. when you showed us the query on PO_LINES_ALL. It ensures that you are using the synonym which you showed us.
Btw. PO_LINES_ALL, could still be a VIEW given your overview of the situation.
Anyway a filter "NULL IS NOT NULL" is indicative that the optimizer performed something called semantic query optimization (SQO).
SQO is the process of deducing new predicates based upon a) existing predicates in your query (which there is none), b) added predicates to your query (eg. by a VPD policy function), and c) declared constraints on the tables invovled in your query.
A typical example of when a "NOT is NOT NULL" predicate will show up is when for instance in the EMP table there is a declared constraint on EMPNO like this:
check(EMPNO > 0)And your query would hold a predicate that is inconsistent with the constraint, for instance like this:
select *
from EMP
where EMPNO <= 0Oracle will deduce that EMPNO cannot be both greater than zero (constraint) as well as smaller than or equal to zero (your query predicate), and will transform the query into:
select *
from EMP
where EMPNO <= 0
and NULL is NOT NULLThus preventing accessing the EMP table all together, and immediately returning this query with no data found.
Edited by: Toon Koppelaars on Mar 15, 2010 7:17 AM -
What are the privileges required for explain plan in Oracle 11g database
I am facing the problem in doing a explain plan for a view in Oracle 11g database. When I select from the view like this:
select * from zonewisearpu
It does a select on the view but when I give explain plan like
explain plan for
select * from zonewisearpu
I get the error like insufficient privileges.
Please let me know if things are getting missed out as I guess system level privileges are required to execute this.
I hope, my question is clear.
It’s a humble request to revert urgently if possible as I need to complete a task and do not know the way out.
Regards975148 wrote:
Thanks for your reply. I have found out that an explain plan is possible on the user's own objects and is not possible on the granted objects from a different schema. For eg, if I do a explain plan on a view querying on tables from a different view, it would not allow the explain plan to proceed. This could mean that explain plan needs different privileges than just a select.
Requesting for a revert to this.
Here is a simple test case that I have perfomed
SQL> create user test1 identified by test1;
User created.
SQL> create user test2 identified by test1;
User created.
SQL> grant connect, resource to test1,test2;
Grant succeeded.
SQL> create table test1.tab1 as select * from v$session;
Table created.
SQL> connect test2/test1
Conencted.
SQL> show user
USER is "TEST2"
SQL>
SQL> explain plan for
2 select sid,serial#,status,username from test1.tab1 where username<> '';
Explained.
SQL>
So, as can be seen I am able to do a explain plan from user test2 for tables belong to user test1.
As far as privileges are concerned, following is the list
SQL> select * from dba_role_privs where grantee in ('TEST1','TEST2') order by 1;
GRANTEE GRANTED_ROLE ADM DEF
TEST1 CONNECT NO YES
TEST1 RESOURCE NO YES
TEST2 CONNECT NO YES
TEST2 RESOURCE NO YES
SQL>
SQL> select grantee,owner,table_name,privilege from dba_tab_privs where grantee in ('TEST1','TEST2') order by 1;
GRANTEE OWNER TABLE_NAME PRIVILEGE
TEST2 TEST1 TAB1 SELECT
SQL>
SQL> select * from dba_sys_privs where grantee in ('TEST1','TEST2') order by 1;
GRANTEE PRIVILEGE ADM
TEST1 UNLIMITED TABLESPACE NO
TEST2 UNLIMITED TABLESPACE NO
SQL> -
Ora-01039 - Insuffficient priviliges - Tuning using Explain Plan
In a TEST instance, i am trying (as the APPS user) on a 9.2.0.5 DB (11.5.10.2) trying to run an explain plan on a query but keep getting the 'ora-01039 - Insuffficient privileges on underlying objects of view' error message.
I have granted 'select any dictionary' to both the APPS and APPLSYS users - but this does not seem to enable the explain plan to work.
Could someone please shed some light on this?
TksYou seem to be doin an Explain Plan on a query against a custom view against non-Apps objects.
Explain Plan needs to be able to "see" the underlying tables (in that other schema).
See :
SQL> create view his_cntry_vw as select * from my_cntry;
View created.
SQL> grant select on his_cntry_vw to abc;
Grant succeeded.
SQL> connect abc/abc
Connected.
SQL> create synonym his_cntry_vw for otheruser.his_cntry_vw;
Synonym created.
SQL> select * from his_cntry_vw;
GRP_I CNTRY
ABC Z9
XYZ UK
SQL> explain plan for select * from his_cntry_vw;
explain plan for select * from his_cntry_vw
ERROR at line 1:
ORA-01039: insufficient privileges on underlying objects of the view
SQL> REM THIS IS THE FIX :
SQL> connect otheruser/otheruser
Connected.
SQL> grant select on my_cntry to abc;
Grant succeeded.
SQL> connect abc/abc
Connected.
SQL> explain plan for select * from his_cntry_vw;
Explained.
SQL>Hemant K Chitale
http://hemantoracledba.blogspot.com -
Explain plan for query with variables
Trying to Explain plan for some sql in sql*plus. The query has a variable in it. How do I do this ?
I did look into explain plan and dbms_xplan but could not find anything with variablesuse sqlplus bind variables:
SQL> --define variable
SQL> var x varchar2
SQL> -- notice the colon prefixing the variable
SQL> explain plan for select * from customer where cid = :x;
Explained.
SQL> select * from table( dbms_xplan.display );
PLAN_TABLE_OUTPUT
Plan hash value: 1709312366
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 67 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| CUSTOMER | 1 | 67 | 2 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | CID | 1 | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("CID"=:X)
14 rows selected.the variable does not need to be set to explain the query, since explain does not actually execute.
Edited by: shoblock on Nov 6, 2008 4:51 PM -
Hi,
can anybody point me to very details of this Plan, specifically how to understand syntax in "3-filter..." statement marked in red.
This about cross join. I expect to see <> (not equal sign) between those columns but there is nothing:
Also actual results is 14 rows, but I don't see this number anywhere in the plan, only "12", should be any correlation between plan and result numbers?
T1 (col_1 number):
1
2
3
4
T2 (col_1 number):
3
4
5
6
SQL> explain plan for select t1.col_1 from t1, t2 where t1.col_1 != t2.col_1;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 1967407726
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 12 | 312 | 6 (0)| 00:00:01 |
| 1 | NESTED LOOPS | | 12 | 312 | 6 (0)| 00:00:01 |
| 2 | TABLE ACCESS FULL| T1 | 4 | 52 | 2 (0)| 00:00:01 |
|* 3 | TABLE ACCESS FULL| T2 | 3 | 39 | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
3 - filter("T1"."COL_1""T2"."COL_1") ---/*XXX
Note
- dynamic sampling used for this statementthe cost based optimizer uses internal statistics to determine the number of rows an operation will return. For the simple query in your example these estimates would be quite exact if the statistics were adequate - but they are not since we see the dynamic sampling note that indicates missing statistics: http://blogs.oracle.com/optimizer/entry/dynamic_sampling_and_its_impact_on_the_optimizer
-- without statistics
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 12 | 312 | 13 (0)| 00:00:01 |
| 1 | NESTED LOOPS | | 12 | 312 | 13 (0)| 00:00:01 |
| 2 | TABLE ACCESS FULL| T1 | 4 | 52 | 4 (0)| 00:00:01 |
|* 3 | TABLE ACCESS FULL| T2 | 3 | 39 | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
3 - filter("T1"."ID"<>"T2"."ID")
Note
- dynamic sampling used for this statement (level=2)
-- gather statistics
exec dbms_stats.gather_table_stats(user, 'T1')
exec dbms_stats.gather_table_stats(user, 'T2')
-- with statistics (we see the 4 * 4 = 16 rows we expect)
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 16 | 96 | 13 (0)| 00:00:01 |
| 1 | NESTED LOOPS | | 16 | 96 | 13 (0)| 00:00:01 |
| 2 | TABLE ACCESS FULL| T1 | 4 | 12 | 4 (0)| 00:00:01 |
|* 3 | TABLE ACCESS FULL| T2 | 4 | 12 | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
3 - filter("T1"."ID"<>"T2"."ID")The filter says that the results of the full scan in Operation 3 are filtered according to the given condition. If we had indexes we would perhaps see an access predicate.
Regards
Martin Preiss -
ERROR: insufficient privileges while using EXPLAIN PLAN command
Hi,
I have a table named TEST and i ran following command on this table.
SQL> EXPLAIN PLAN FOR
2 SELECT NAME FROM TEST;
SELECT NAME FROM TEST
ERROR at line 2:
ORA-01031: insufficient privileges
So which privilege do i need to give for using EXPLAIN PLAN command.
Thank.http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14211/ex_plan.htm#i19260
SQL> @C:\oracle\product\10.2.0\db_1\RDBMS\ADMIN\utlxplan.sql
Table created.
SQL> select table_name from user_tables where table_name='PLAN_TABLE';
TABLE_NAME
PLAN_TABLE
You might consider checking dba_tables to check the owner in your case and may be you don't privilege on that table. -
The below same query runs fast at PL/SQL , while the same query run from front end (EBS R 12.0.4) using concurrent request runs verl slow , both has diffrent plan , please share some thought.
Below query when i run from backend (PL/SQL Developer) it returns row within a second
SELECT /*+ gather_plan_statistics product_item_2.txt */ OH.ORG_ID,BUNIT.BU_ID,OL.INVENTORY_ITEM_ID,CUST.account_number,CUST.ACCOUNT_NAME,CUST.CUSTOMER_CLASS_CODE,
NVL(SUM(OL.FULFILLED_QUANTITY),0) as sale_qty
FROM
OE_ORDER_HEADERS_ALL OH,OE_ORDER_LINES_ALL OL,
HZ_CUST_ACCOUNTS CUST,mtl_categories_vl CAT,
mtl_item_categories IC,(select FLEX_VALUE BU_ID,DESCRIPTION B_NAME from fnd_flex_values_vl t
where t.FLEX_VALUE_SET_ID ='1012990') BUNIT
WHERE OH.HEADER_ID = OL.HEADER_ID
AND CUST.CUST_ACCOUNT_ID =
(SELECT DISTINCT ACCT.CUST_ACCOUNT_ID
FROM HZ_CUST_ACCOUNTS ACCT,HZ_CUST_ACCT_SITES_ALL ACCT_SITE,
HZ_LOCATIONS LOC,HZ_PARTY_SITES PARTY_SITE,
HZ_CUST_SITE_USES_ALL SUSE,HZ_PARTIES P
WHERE ACCT.PARTY_ID = PARTY_SITE.PARTY_ID
AND ACCT.CUST_ACCOUNT_ID = ACCT_SITE.CUST_ACCOUNT_ID
AND SUSE.CUST_ACCT_SITE_ID = ACCT_SITE.CUST_ACCT_SITE_ID
AND ACCT_SITE.PARTY_SITE_ID = PARTY_SITE.PARTY_SITE_ID
AND LOC.LOCATION_ID = PARTY_SITE.LOCATION_ID
AND SUSE.SITE_USE_ID = OL.SHIP_TO_ORG_ID
AND P.PARTY_ID = ACCT.PARTY_ID
AND P.PARTY_ID = PARTY_SITE.PARTY_ID
AND SUSE.SITE_USE_CODE = 'SHIP_TO'
AND ACCT_SITE.ORG_ID = &P_ORG_ID
AND OH.ORG_ID = &P_ORG_ID
AND OL.ACTUAL_SHIPMENT_DATE BETWEEN &P_FROM_DATE AND &P_TO_DATE
AND OL.UNIT_SELLING_PRICE != 0
AND OL.LINE_CATEGORY_CODE = 'ORDER'
AND OL.ORDERED_ITEM = NVL(&ITEM_HIGH, OL.ORDERED_ITEM)
AND BUNIT.BU_ID = nvl(&p_business_unit,bunit.bu_id)
AND CAT.CATEGORY_ID = IC.CATEGORY_ID
AND CAT.STRUCTURE_ID = 50289
AND IC.INVENTORY_ITEM_ID = OL.INVENTORY_ITEM_ID
AND IC.ORGANIZATION_ID = OH.SHIP_FROM_ORG_ID
and cat.SEGMENT3 = BUNIT.BU_ID
GROUP BY
OH.ORG_ID,BUNIT.BU_ID,OL.INVENTORY_ITEM_ID,CUST.account_number,CUST.ACCOUNT_NAME,CUST.CUSTOMER_CLASS_CODE
ORDER BY 1Plan for above query is as follows
SQL> set pagesize 1000
SQL> /
PLAN_TABLE_OUTPUT
SQL_ID 5g71mvqaat8x3, child number 0
Plan hash value: 610424373
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
| 1 | HASH GROUP BY | | 1 | 1 | 2 |00:00:00.64 | 144K| | | |
| 2 | NESTED LOOPS | | 1 | 1 | 71 |00:00:00.30 | 144K| | | |
| 3 | NESTED LOOPS | | 1 | 1 | 1704 |00:00:00.26 | 138K| | | |
|* 4 | HASH JOIN | | 1 | 1 | 3312 |00:00:00.05 | 132K| 887K| 887K| 1236K (0)|
| 5 | TABLE ACCESS BY INDEX ROWID | MTL_ITEM_CATEGORIES | 1 | 506 | 1075 |00:00:00.02 | 361 | | | |
| 6 | NESTED LOOPS | | 1 | 1 | 1077 |00:00:00.04 | 24 | | | |
| 7 | NESTED LOOPS | | 1 | 1 | 1 |00:00:00.01 | 19 | | | |
| 8 | NESTED LOOPS | | 1 | 1 | 1 |00:00:00.01 | 18 | | | |
| 9 | NESTED LOOPS | | 1 | 1 | 1 |00:00:00.01 | 15 | | | |
|* 10 | TABLE ACCESS BY INDEX ROWID | FND_FLEX_VALUES | 1 | 1 | 1 |00:00:00.01 | 13 | | | |
|* 11 | INDEX RANGE SCAN | IDX$$_65860003 | 1 | 22 | 52 |00:00:00.01 | 2 | | | |
|* 12 | INDEX UNIQUE SCAN | FND_FLEX_VALUES_TL_U1 | 1 | 1 | 1 |00:00:00.01 | 2 | | | |
|* 13 | TABLE ACCESS BY INDEX ROWID | MTL_CATEGORIES_B | 1 | 1 | 1 |00:00:00.01 | 3 | | | |
|* 14 | INDEX RANGE SCAN | IDX$$_79530001 | 1 | 1 | 2 |00:00:00.01 | 1 | | | |
|* 15 | INDEX UNIQUE SCAN | MTL_CATEGORIES_TL_U1 | 1 | 1 | 1 |00:00:00.01 | 1 | | | |
|* 16 | INDEX RANGE SCAN | IDX$$_78250002 | 1 | 1528 | 1075 |00:00:00.01 | 5 | | | |
|* 17 | TABLE ACCESS BY INDEX ROWID | OE_ORDER_LINES_ALL | 1 | 51 | 138 |00:00:00.01 | 132K| | | |
|* 18 | INDEX SKIP SCAN | OE_ORDER_LINES_N26 | 1 | 14977 | 113K|00:00:00.57 | 1208 | | | |
| 19 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCOUNTS | 3312 | 1 | 1704 |00:00:00.09 | 5188 | | | |
|* 20 | INDEX UNIQUE SCAN | HZ_CUST_ACCOUNTS_U1 | 3312 | 1 | 1704 |00:00:00.04 | 3484 | | | |
| 21 | NESTED LOOPS | | 8 | 1 | 2 |00:00:00.01 | 76 | | | |
| 22 | NESTED LOOPS | | 8 | 1 | 2 |00:00:00.01 | 72 | | | |
| 23 | NESTED LOOPS | | 8 | 1 | 2 |00:00:00.01 | 66 | | | |
| 24 | NESTED LOOPS | | 8 | 1 | 2 |00:00:00.01 | 62 | | | |
| 25 | NESTED LOOPS | | 8 | 1 | 2 |00:00:00.01 | 56 | | | |
|* 26 | TABLE ACCESS BY INDEX ROWID| HZ_CUST_SITE_USES_ALL | 8 | 1 | 8 |00:00:00.01 | 32 | | | |
|* 27 | INDEX UNIQUE SCAN | HZ_CUST_SITE_USES_U1 | 8 | 1 | 8 |00:00:00.01 | 24 | | | |
|* 28 | TABLE ACCESS BY INDEX ROWID| HZ_CUST_ACCT_SITES_ALL | 8 | 25087 | 2 |00:00:00.01 | 24 | | | |
|* 29 | INDEX UNIQUE SCAN | HZ_CUST_ACCT_SITES_U1 | 8 | 1 | 8 |00:00:00.01 | 16 | | | |
| 30 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCOUNTS | 2 | 176K| 2 |00:00:00.01 | 6 | | | |
|* 31 | INDEX UNIQUE SCAN | HZ_CUST_ACCOUNTS_U1 | 2 | 1 | 2 |00:00:00.01 | 4 | | | |
|* 32 | INDEX UNIQUE SCAN | HZ_PARTIES_U1 | 2 | 176K| 2 |00:00:00.01 | 4 | | | |
|* 33 | TABLE ACCESS BY INDEX ROWID | HZ_PARTY_SITES | 2 | 188K| 2 |00:00:00.01 | 6 | | | |
|* 34 | INDEX UNIQUE SCAN | HZ_PARTY_SITES_U1 | 2 | 1 | 2 |00:00:00.01 | 4 | | | |
|* 35 | INDEX UNIQUE SCAN | HZ_LOCATIONS_U1 | 2 | 174K| 2 |00:00:00.01 | 4 | | | |
|* 36 | TABLE ACCESS BY INDEX ROWID | OE_ORDER_HEADERS_ALL | 1704 | 1 | 71 |00:00:00.05 | 6816 | | | |
|* 37 | INDEX UNIQUE SCAN | OE_ORDER_HEADERS_U1 | 1704 | 1 | 1704 |00:00:00.03 | 5112 | | | |
Predicate Information (identified by operation id):
4 - access("IC"."INVENTORY_ITEM_ID"="OL"."INVENTORY_ITEM_ID")
10 - filter("B"."FLEX_VALUE"=NVL('02',"B"."FLEX_VALUE"))
11 - access("B"."FLEX_VALUE_SET_ID"=1012990)
12 - access("B"."FLEX_VALUE_ID"="T"."FLEX_VALUE_ID" AND "T"."LANGUAGE"=USERENV('LANG'))
13 - filter("B"."STRUCTURE_ID"=50289)
14 - access("B"."SEGMENT3"="B"."FLEX_VALUE")
filter("B"."SEGMENT3" IS NOT NULL)
15 - access("B"."CATEGORY_ID"="T"."CATEGORY_ID" AND "T"."LANGUAGE"=USERENV('LANG'))
16 - access("B"."CATEGORY_ID"="IC"."CATEGORY_ID")
17 - filter(("OL"."ORDERED_ITEM"=NVL('101468',"OL"."ORDERED_ITEM") AND "OL"."UNIT_SELLING_PRICE"<>0))
18 - access("OL"."LINE_CATEGORY_CODE"='ORDER' AND "OL"."ACTUAL_SHIPMENT_DATE">=TO_DATE('2012-02-20 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND
"OL"."ACTUAL_SHIPMENT_DATE"<=TO_DATE('2012-02-23 00:00:00', 'yyyy-mm-dd hh24:mi:ss'))
filter(("OL"."ACTUAL_SHIPMENT_DATE">=TO_DATE('2012-02-20 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND "OL"."LINE_CATEGORY_CODE"='ORDER'
AND "OL"."ACTUAL_SHIPMENT_DATE"<=TO_DATE('2012-02-23 00:00:00', 'yyyy-mm-dd hh24:mi:ss')))
20 - access("CUST"."CUST_ACCOUNT_ID"=)
26 - filter("SUSE"."SITE_USE_CODE"='SHIP_TO')
27 - access("SUSE"."SITE_USE_ID"=:B1)
28 - filter("ACCT_SITE"."ORG_ID"=142)
29 - access("SUSE"."CUST_ACCT_SITE_ID"="ACCT_SITE"."CUST_ACCT_SITE_ID")
31 - access("ACCT"."CUST_ACCOUNT_ID"="ACCT_SITE"."CUST_ACCOUNT_ID")
32 - access("P"."PARTY_ID"="ACCT"."PARTY_ID")
33 - filter(("ACCT"."PARTY_ID"="PARTY_SITE"."PARTY_ID" AND "P"."PARTY_ID"="PARTY_SITE"."PARTY_ID"))
34 - access("ACCT_SITE"."PARTY_SITE_ID"="PARTY_SITE"."PARTY_SITE_ID")
35 - access("LOC"."LOCATION_ID"="PARTY_SITE"."LOCATION_ID")
36 - filter(("OH"."ORG_ID"=142 AND "IC"."ORGANIZATION_ID"="OH"."SHIP_FROM_ORG_ID"))
37 - access("OH"."HEADER_ID"="OL"."HEADER_ID")
85 rows selected.Below plan for the above same query when i run from front end concurrent request it completed within an hour.
SQL> select * from table(dbms_xplan.display_cursor('1gnb26b0q2vxx',NULL,'ALLSTATS LAST'))
2 /
PLAN_TABLE_OUTPUT
SQL_ID 1gnb26b0q2vxx, child number 0
Plan hash value: 408306916
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
| 1 | HASH GROUP BY | | 1 | 1 | 2 |00:36:41.83 | 379M| | | |
| 2 | CONCATENATION | | 1 | | 71 |00:09:30.14 | 379M| | | |
|* 3 | FILTER | | 1 | | 0 |00:00:00.01 | 0 | | | |
| 4 | NESTED LOOPS | | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
| 5 | NESTED LOOPS | | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
|* 6 | HASH JOIN | | 0 | 4 | 0 |00:00:00.01 | 0 | 715K| 715K| |
| 7 | TABLE ACCESS BY INDEX ROWID | MTL_ITEM_CATEGORIES | 0 | 506 | 0 |00:00:00.01 | 0 | | | |
| 8 | NESTED LOOPS | | 0 | 26 | 0 |00:00:00.01 | 0 | | | |
| 9 | NESTED LOOPS | | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
| 10 | NESTED LOOPS | | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
| 11 | NESTED LOOPS | | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
|* 12 | TABLE ACCESS BY INDEX ROWID| FND_FLEX_VALUES | 0 | 22 | 0 |00:00:00.01 | 0 | | | |
|* 13 | INDEX RANGE SCAN | IDX$$_65860003 | 0 | 22 | 0 |00:00:00.01 | 0 | | | |
|* 14 | TABLE ACCESS BY INDEX ROWID| MTL_CATEGORIES_B | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
|* 15 | INDEX RANGE SCAN | MTL_CATEGORIES_B_N3 | 0 | 2 | 0 |00:00:00.01 | 0 | | | |
|* 16 | INDEX UNIQUE SCAN | FND_FLEX_VALUES_TL_U1 | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
|* 17 | INDEX UNIQUE SCAN | MTL_CATEGORIES_TL_U1 | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
|* 18 | INDEX RANGE SCAN | IDX$$_78250002 | 0 | 1528 | 0 |00:00:00.01 | 0 | | | |
|* 19 | TABLE ACCESS FULL | OE_ORDER_LINES_ALL | 0 | 97 | 0 |00:00:00.01 | 0 | | | |
|* 20 | TABLE ACCESS BY INDEX ROWID | OE_ORDER_HEADERS_ALL | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
|* 21 | INDEX UNIQUE SCAN | OE_ORDER_HEADERS_U1 | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
| 22 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCOUNTS | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
|* 23 | INDEX UNIQUE SCAN | HZ_CUST_ACCOUNTS_U1 | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
| 24 | NESTED LOOPS | | 2 | 1 | 2 |00:00:00.01 | 34 | | | |
| 25 | NESTED LOOPS | | 2 | 1 | 2 |00:00:00.01 | 30 | | | |
| 26 | NESTED LOOPS | | 2 | 1 | 2 |00:00:00.01 | 24 | | | |
| 27 | NESTED LOOPS | | 2 | 1 | 2 |00:00:00.01 | 20 | | | |
| 28 | NESTED LOOPS | | 2 | 1 | 2 |00:00:00.01 | 14 | | | |
|* 29 | TABLE ACCESS BY INDEX ROWID| HZ_CUST_SITE_USES_ALL | 2 | 1 | 2 |00:00:00.01 | 8 | | | |
|* 30 | INDEX UNIQUE SCAN | HZ_CUST_SITE_USES_U1 | 2 | 1 | 2 |00:00:00.01 | 6 | | | |
|* 31 | TABLE ACCESS BY INDEX ROWID| HZ_CUST_ACCT_SITES_ALL | 2 | 9420 | 2 |00:00:00.01 | 6 | | | |
|* 32 | INDEX UNIQUE SCAN | HZ_CUST_ACCT_SITES_U1 | 2 | 1 | 2 |00:00:00.01 | 4 | | | |
| 33 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCOUNTS | 2 | 176K| 2 |00:00:00.01 | 6 | | | |
|* 34 | INDEX UNIQUE SCAN | HZ_CUST_ACCOUNTS_U1 | 2 | 1 | 2 |00:00:00.01 | 4 | | | |
|* 35 | INDEX UNIQUE SCAN | HZ_PARTIES_U1 | 2 | 176K| 2 |00:00:00.01 | 4 | | | |
|* 36 | TABLE ACCESS BY INDEX ROWID | HZ_PARTY_SITES | 2 | 188K| 2 |00:00:00.01 | 6 | | | |
|* 37 | INDEX UNIQUE SCAN | HZ_PARTY_SITES_U1 | 2 | 1 | 2 |00:00:00.01 | 4 | | | |
|* 38 | INDEX UNIQUE SCAN | HZ_LOCATIONS_U1 | 2 | 174K| 2 |00:00:00.01 | 4 | | | |
|* 39 | FILTER | | 1 | | 71 |00:09:30.14 | 379M| | | |
| 40 | NESTED LOOPS | | 1 | 1 | 71 |00:09:30.14 | 379M| | | |
| 41 | NESTED LOOPS | | 1 | 1 | 71 |00:09:30.11 | 379M| | | |
| 42 | NESTED LOOPS | | 1 | 18 | 16M|00:03:49.48 | 34M| | | |
| 43 | NESTED LOOPS | | 1 | 1 | 1075 |00:00:00.03 | 351 | | | |
| 44 | NESTED LOOPS | | 1 | 1 | 1 |00:00:00.01 | 9 | | | |
| 45 | NESTED LOOPS | | 1 | 1 | 1 |00:00:00.01 | 8 | | | |
| 46 | NESTED LOOPS | | 1 | 1 | 1 |00:00:00.01 | 6 | | | |
| 47 | TABLE ACCESS BY INDEX ROWID | FND_FLEX_VALUES | 1 | 1 | 1 |00:00:00.01 | 3 | | | |
|* 48 | INDEX RANGE SCAN | FND_FLEX_VALUES_N4 | 1 | 1 | 1 |00:00:00.01 | 2 | | | |
|* 49 | TABLE ACCESS BY INDEX ROWID | MTL_CATEGORIES_B | 1 | 1 | 1 |00:00:00.01 | 3 | | | |
|* 50 | INDEX RANGE SCAN | IDX$$_79530001 | 1 | 1 | 2 |00:00:00.01 | 1 | | | |
|* 51 | INDEX UNIQUE SCAN | FND_FLEX_VALUES_TL_U1 | 1 | 1 | 1 |00:00:00.01 | 2 | | | |
|* 52 | INDEX UNIQUE SCAN | MTL_CATEGORIES_TL_U1 | 1 | 1 | 1 |00:00:00.01 | 1 | | | |
| 53 | TABLE ACCESS BY INDEX ROWID | MTL_ITEM_CATEGORIES | 1 | 506 | 1075 |00:00:00.02 | 342 | | | |
|* 54 | INDEX RANGE SCAN | IDX$$_78250002 | 1 | 1528 | 1075 |00:00:00.01 | 5 | | | |
|* 55 | TABLE ACCESS BY INDEX ROWID | OE_ORDER_HEADERS_ALL | 1075 | 6485 | 16M|00:12:38.97 | 34M| | | |
|* 56 | INDEX RANGE SCAN | OE_ORDER_HEADER_ALL_ORG_ID_NDX | 1075 | 141K| 394M|00:19:52.50 | 2141K| | | |
|* 57 | TABLE ACCESS BY INDEX ROWID | OE_ORDER_LINES_ALL | 16M| 1 | 71 |00:23:47.72 | 345M| | | |
|* 58 | INDEX RANGE SCAN | OE_ORDER_LINES_N21 | 16M| 6 | 108M|00:08:35.98 | 32M| | | |
| 59 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCOUNTS | 71 | 1 | 71 |00:00:00.01 | 247 | | | |
|* 60 | INDEX UNIQUE SCAN | HZ_CUST_ACCOUNTS_U1 | 71 | 1 | 71 |00:00:00.01 | 176 | | | |
| 61 | NESTED LOOPS | | 2 | 1 | 2 |00:00:00.01 | 34 | | | |
| 62 | NESTED LOOPS | | 2 | 1 | 2 |00:00:00.01 | 30 | | | |
| 63 | NESTED LOOPS | | 2 | 1 | 2 |00:00:00.01 | 24 | | | |
| 64 | NESTED LOOPS | | 2 | 1 | 2 |00:00:00.01 | 20 | | | |
| 65 | NESTED LOOPS | | 2 | 1 | 2 |00:00:00.01 | 14 | | | |
|* 66 | TABLE ACCESS BY INDEX ROWID| HZ_CUST_SITE_USES_ALL | 2 | 1 | 2 |00:00:00.01 | 8 | | | |
|* 67 | INDEX UNIQUE SCAN | HZ_CUST_SITE_USES_U1 | 2 | 1 | 2 |00:00:00.01 | 6 | | | |
|* 68 | TABLE ACCESS BY INDEX ROWID| HZ_CUST_ACCT_SITES_ALL | 2 | 9420 | 2 |00:00:00.01 | 6 | | | |
|* 69 | INDEX UNIQUE SCAN | HZ_CUST_ACCT_SITES_U1 | 2 | 1 | 2 |00:00:00.01 | 4 | | | |
| 70 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCOUNTS | 2 | 176K| 2 |00:00:00.01 | 6 | | | |
|* 71 | INDEX UNIQUE SCAN | HZ_CUST_ACCOUNTS_U1 | 2 | 1 | 2 |00:00:00.01 | 4 | | | |
|* 72 | INDEX UNIQUE SCAN | HZ_PARTIES_U1 | 2 | 176K| 2 |00:00:00.01 | 4 | | | |
|* 73 | TABLE ACCESS BY INDEX ROWID | HZ_PARTY_SITES | 2 | 188K| 2 |00:00:00.01 | 6 | | | |
|* 74 | INDEX UNIQUE SCAN | HZ_PARTY_SITES_U1 | 2 | 1 | 2 |00:00:00.01 | 4 | | | |
|* 75 | INDEX UNIQUE SCAN | HZ_LOCATIONS_U1 | 2 | 174K| 2 |00:00:00.01 | 4 | | | |
Predicate Information (identified by operation id):
3 - filter((:P_FROM_DATE<=:P_TO_DATE AND :P_BUSINESS_UNIT IS NULL))
6 - access("IC"."INVENTORY_ITEM_ID"="OL"."INVENTORY_ITEM_ID")
12 - filter("B"."FLEX_VALUE" IS NOT NULL)
13 - access("B"."FLEX_VALUE_SET_ID"=1012990)
14 - filter("B"."STRUCTURE_ID"=50289)
15 - access("B"."SEGMENT3"="B"."FLEX_VALUE")
filter("B"."SEGMENT3" IS NOT NULL)
16 - access("B"."FLEX_VALUE_ID"="T"."FLEX_VALUE_ID" AND "T"."LANGUAGE"=USERENV('LANG'))
17 - access("B"."CATEGORY_ID"="T"."CATEGORY_ID" AND "T"."LANGUAGE"=USERENV('LANG'))
18 - access("B"."CATEGORY_ID"="IC"."CATEGORY_ID")
19 - filter(("OL"."ACTUAL_SHIPMENT_DATE">=:P_FROM_DATE AND "OL"."ACTUAL_SHIPMENT_DATE"<=:P_TO_DATE AND
"OL"."ORDERED_ITEM"=NVL(:ITEM_HIGH,"OL"."ORDERED_ITEM") AND "OL"."LINE_CATEGORY_CODE"='ORDER' AND "OL"."UNIT_SELLING_PRICE"<>0))
20 - filter(("OH"."ORG_ID"=:P_ORG_ID AND "IC"."ORGANIZATION_ID"="OH"."SHIP_FROM_ORG_ID"))
21 - access("OH"."HEADER_ID"="OL"."HEADER_ID")
23 - access("CUST"."CUST_ACCOUNT_ID"=)
29 - filter("SUSE"."SITE_USE_CODE"='SHIP_TO')
30 - access("SUSE"."SITE_USE_ID"=:B1)
31 - filter("ACCT_SITE"."ORG_ID"=:P_ORG_ID)
32 - access("SUSE"."CUST_ACCT_SITE_ID"="ACCT_SITE"."CUST_ACCT_SITE_ID")
34 - access("ACCT"."CUST_ACCOUNT_ID"="ACCT_SITE"."CUST_ACCOUNT_ID")
35 - access("P"."PARTY_ID"="ACCT"."PARTY_ID")
36 - filter(("ACCT"."PARTY_ID"="PARTY_SITE"."PARTY_ID" AND "P"."PARTY_ID"="PARTY_SITE"."PARTY_ID"))
37 - access("ACCT_SITE"."PARTY_SITE_ID"="PARTY_SITE"."PARTY_SITE_ID")
38 - access("LOC"."LOCATION_ID"="PARTY_SITE"."LOCATION_ID")
39 - filter((:P_FROM_DATE<=:P_TO_DATE AND :P_BUSINESS_UNIT IS NOT NULL))
48 - access("B"."FLEX_VALUE"=:P_BUSINESS_UNIT AND "B"."FLEX_VALUE_SET_ID"=1012990)
49 - filter("B"."STRUCTURE_ID"=50289)
50 - access("B"."SEGMENT3"="B"."FLEX_VALUE")
filter("B"."SEGMENT3" IS NOT NULL)
51 - access("B"."FLEX_VALUE_ID"="T"."FLEX_VALUE_ID" AND "T"."LANGUAGE"=USERENV('LANG'))
52 - access("B"."CATEGORY_ID"="T"."CATEGORY_ID" AND "T"."LANGUAGE"=USERENV('LANG'))
54 - access("B"."CATEGORY_ID"="IC"."CATEGORY_ID")
55 - filter("IC"."ORGANIZATION_ID"="OH"."SHIP_FROM_ORG_ID")
56 - access("OH"."ORG_ID"=:P_ORG_ID)
57 - filter(("OL"."ACTUAL_SHIPMENT_DATE">=:P_FROM_DATE AND "OL"."ACTUAL_SHIPMENT_DATE"<=:P_TO_DATE AND
"OL"."ORDERED_ITEM"=NVL(:ITEM_HIGH,"OL"."ORDERED_ITEM") AND "OL"."LINE_CATEGORY_CODE"='ORDER' AND "OL"."UNIT_SELLING_PRICE"<>0 AND
"IC"."INVENTORY_ITEM_ID"="OL"."INVENTORY_ITEM_ID"))
58 - access("OH"."HEADER_ID"="OL"."HEADER_ID")
60 - access("CUST"."CUST_ACCOUNT_ID"=)
66 - filter("SUSE"."SITE_USE_CODE"='SHIP_TO')
67 - access("SUSE"."SITE_USE_ID"=:B1)
68 - filter("ACCT_SITE"."ORG_ID"=:P_ORG_ID)
69 - access("SUSE"."CUST_ACCT_SITE_ID"="ACCT_SITE"."CUST_ACCT_SITE_ID")
71 - access("ACCT"."CUST_ACCOUNT_ID"="ACCT_SITE"."CUST_ACCOUNT_ID")
72 - access("P"."PARTY_ID"="ACCT"."PARTY_ID")
73 - filter(("ACCT"."PARTY_ID"="PARTY_SITE"."PARTY_ID" AND "P"."PARTY_ID"="PARTY_SITE"."PARTY_ID"))
74 - access("ACCT_SITE"."PARTY_SITE_ID"="PARTY_SITE"."PARTY_SITE_ID")
75 - access("LOC"."LOCATION_ID"="PARTY_SITE"."LOCATION_ID")
145 rows selected.one thing looking strange at predicate section at line 23 and 60 access("CUST"."CUST_ACCOUNT_ID"=),Plan is also differing why?Just look at filter predicates 3 and 39 which I highlighted previously.
With a query using bind variable, p_business_unit might be supplied with a null value and therefore two possible paths exist in the CONCATENTATION plan to cope with those possibilities (and the possibility that P_FROM_DATE is not <= P_TO_DATE).
If instead of using bind variable you supply a literal - i.e. '101468' - then the optimizer doesn't not have to worry about the fact that '101468' might be null. As far as this piece of SQL is concerned, it's a constant.
Therefore you shouldn't compare SQL that runs with binds with SQl that runs with literals, particularly where the sql involves conditional predicates.
To use a simplification, consider the difference here:
SQL> explain plan for
2 select 1 from dual where 1 = nvl(1,1);
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 1388734953
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 2 (0)| 00:00:01 |
| 1 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
8 rows selected.
SQL> explain plan for
2 select 1 from dual where 1 = nvl(:1,1);
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 4034615273
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 2 (0)| 00:00:01 |
|* 1 | FILTER | | | | |
| 2 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter(NVL(:1,1)=1)
14 rows selected.Furthermore, to emphasis my point about substition variables (&variable_name) consider this:
SQL> explain plan for
2 select 1 from dual where 1 = nvl(&1,1);
Enter value for 1: 1
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 1388734953
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 2 (0)| 00:00:01 |
| 1 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
8 rows selected.
SQL> Does the substitution variable behave like a bind variable or like a literal?
A literal, because that's what it is. Substituted in before the statement is sent to the database and parsed. -
Oracle 11.2.0.1
Windows
SQL> show user;
USER is "SCOTT"
SQL> set autotrace on;
ERROR:
ORA-06575: Package or function DBMS_XPLAN is in an invalid state
SP2-0611: Error enabling EXPLAIN report
SQL> connect hr/hr
Connected.
SQL> set autotrace on;
SQL>
Why Scott user is getting above error and how do I correct this please help me.
Thanks.Thank you so much sir. You are 100% correct.
SQL> select object_type,object_name
2 from user_objects
3 where object_name like '%PLAN%';
OBJECT_TYPE OBJECT_NAME
PACKAGE DBMS_XPLAN
LIBRARY DBMS_XPLAN_LIB
TABLE PLAN_TABLE
SQL> drop table plan_table purge;
Table dropped.
SQL> drop package dbms_xplan;
Package dropped.
SQL> select object_type,object_name
2 from user_objects
3 where object_name like '%PLAN%';
OBJECT_TYPE OBJECT_NAME
LIBRARY DBMS_XPLAN_LIB
SQL> drop library dbms_xplan_lib;
Library dropped.
SQL> set autotrace on;
SQL> explain plan for select * from emp;
Explained.
SQL> SET LINESIZE 130
SQL> SET PAGESIZE 0
SQL> SELECT *
2 FROM TABLE(DBMS_XPLAN.DISPLAY);
Plan hash value: 3956160932
and I got the plan.
Thanks again.
Maybe you are looking for
-
Thinkpad X201 - problem with microphone and speakers
Hi, My thinkpad X201 is a professional computer set up with Windows XP. Although I cannot check, I am reasonably sure that the computer was installed with the latest drivers and is regularly updated to the latest SP and patches. My problem is the fol
-
When I try to buy an app it won't let me log in and says that I need to use another Apple ID on my iPad 2
-
Transfer PDF's and books to iPad without erasing other files
I've seen a couple of posts about this issue but I haven't been able to resolve this problem. If I try to sync PDF's or books from my iMac iTunes to my iPad I get this warning -Are you sure you want to sync books? All existing songs, movies and TV sh
-
I have been sending students to adobe.com to use the Adobe TV videos for Elements. They have always been excellent beginner tutorials. For some reason I can still get to them for Elements 11 and Elements 9 but there is only a short list of tutorial
-
Please help a Photoshop newbie recreate a text effect... :(
If someone would be kind enough to help me out on this, I've been working on it for last few hours... the .psd is the effect that I want to accomplish. I downloaded the effect file here: 108 Free Glowing Neon Social Networking Icons » WebTreats ETC W