How to see an explain plan?
Hi all,
I'm looking to tune one sql sentence of my application. To do it, I've used the sqltune package. When I see the report, I obtain the actual explain plan and, finally the suggestion to use an SQL Profile.
How can I see the new explain plan of this option before apply it?
I attach the report result for your information:
SELECT DBMS_SQLTUNE.report_tuning_task('analisis_matriculation_view') AS recommendations FROM dual;SQL> SQL> SQL>
RECOMMENDATIONS
GENERAL INFORMATION SECTION
Tuning Task Name : analisis_matriculation_view
Tuning Task Owner : A9
Scope : COMPREHENSIVE
Time Limit(seconds) : 3600
Completion Status : COMPLETED
Started at : 08/11/2010 09:33:18
Completed at : 08/11/2010 10:23:16
Number of SQL Profile Findings : 1
Schema Name: A9
SQL ID : gd8b5pwyj0yu8
SQL Text : SELECT PO.ID POID, BO.ID BOID, MAT.AGENT_ID AGENTID,
MAT.AGENCY_ID AGENCYID, MAT.ID MATID,MAT.PARTNERBRANCH_ID
PBRANCHID, MAT.DOSSIERNUMBER, MAT.DOSSIERVERSION,
MAT.FILINGDATE,MAT.TELEMATIC, MAT.MANUALDGTTAXCODE,
MAT.ASSIGNDGTTAX, MAT.STATUS, MAT.PLATENUMBER,MAT.REJECTIONCAUSE,
MAT.REJECTIONNOTES, MAT.COLOR, MAT.CREATEDON, MAT.MODIFIEDON,
FO.COLOR,AG.MEMBERID, US.NAME AGENTNAME, US.SURNAME
AGENTSURNAME, US.SURNAME2 AGENTSURNAME2, US.NIF AGENTNIF,AY.NAME
AGENCYNAME, VD.SERIALNUMBER, VOWN.NAME OWNERNAME, VOWN.SURNAME
OWNERSURNAME,VOWN.SURNAME2 OWNERSURNAME2, UPPER(VOWN.NAME) || '
' || UPPER(VOWN.SURNAME) || ' ' || UPPER(VOWN.SURNAME2)
OWNERFULLNAME,VOWN.FISCALID OWNERNIF, FO.ID FOLDERID, FO.NAME
FOLDERNAME, FO.STATUS FOLDERSTATUS, IVTM.ID IVTMID,IVTM.STATUS
IVTMSTATUS, IVTM.FINALAMOUNT IVTMAMOUNT, IVTM.IVTMCOLLECTOR,
F576.ID F576ID,F576.PAYMENTCOMPLETEREFNUMBER NRC576,
F576.MATRICULATIONCODE CEM576, F576.AEATELECTRONICCODEMANUAL
CEM576MANUAL,F576.NRCMANUAL NRC576MANUAL, F06.ID F06ID,
F06.MATRICULATIONCODE CEM06, F06.AEATELECTRONICCODEMANUAL
CEM06MANUAL,F06.NRE NRE06, F06.NREMANUAL NRE06MANUAL, F05.ID
F05ID, F05.MATRICULATIONCODE CEM05, F05.AEATELECTRONICCODEMANUAL
CEM05MANUAL FROM A9_MATRICULATION MAT INNER JOIN A9_AGENT AG ON
(MAT.AGENT_ID = AG.ID) INNER JOIN A9_USER US ON (AG.ID = US.ID)
INNER JOIN A9_BRANCHOFFICE BO ON (AG.BRANCHOFFICE_ID = BO.ID)
INNER JOIN A9_PROFESSIONALORDER PO ON (BO.PROFESSIONALORDER_ID =
PO.ID) INNER JOIN A9_AGENCY AY ON (MAT.AGENCY_ID = AY.ID) INNER
JOIN A9_VEHICLEDATA VD ON (MAT.VEHICLEDATA_ID = VD.ID) INNER
JOIN A9_VEHICLEOWNER VOWN ON (VOWN.MATRICULATION_ID = MAT.ID)
LEFT JOIN A9_MATRICULATIONFOLDER FO ON
(MAT.MATRICULATIONFOLDER_ID = FO.ID) LEFT JOIN A9_IVTM IVTM ON
(MAT.IVTM_ID = IVTM.ID)LEFT JOIN A9_FORM576 F576 ON
(MAT.FORM576_ID = F576.ID) LEFT JOIN A9_FORM05 F05 ON
(MAT.FORM05_ID = F05.ID) LEFT JOIN A9_FORM06 F06 ON
(MAT.FORM06_ID = F06.ID) WHERE VOWN.MAINOWNER = 1 AND MAT.VALID
= 1 AND US.DELETEDON IS NULL AND PO.DELETEDON IS NULL AND
BO.DELETEDON IS NULL AND AY.DELETEDON IS NULL AND VOWN.DELETEDON
IS NULL AND FO.DELETEDON IS NULL AND IVTM.DELETEDON IS NULL AND
VD.DELETEDON IS NULL AND F576.DELETEDON IS NULL AND
F05.DELETEDON IS NULL AND F06.DELETEDON IS NULL AND
MAT.DELETEDON IS NULL ORDER BY DOSSIERNUMBER DESC
FINDINGS SECTION (1 finding)
1- SQL Profile Finding (see explain plans section below)
Se ha encontrado un plan de ejecucion potencialmente mejor para esta
sentencia.
Recommendation (estimated benefit: 35,82%)
- Puede aceptar el perfil SQL recomendado.
execute dbms_sqltune.accept_sql_profile(task_name =>
'analisis_matriculation_view', replace => TRUE);
EXPLAIN PLANS SECTION
1- Original With Adjusted Cost
Plan hash value: 1271206505
Id Operation Name Rows Bytes TempSpc Cost (%CPU) Time
0 SELECT STATEMENT 4728K 2015M 783K (1) 02:36:41
1 SORT ORDER BY 4728K 2015M 4346M 783K (1) 02:36:41
* 2 HASH JOIN 4728K 2015M 1857M 333K (1) 01:06:48
* 3 HASH JOIN 4728K 1803M 1736M 231K (1) 00:46:14
* 4 HASH JOIN 4728K 1682M 133K (1) 00:26:42
* 5 TABLE ACCESS FULL A9_AGENCY 1076 34432 8 (0) 00:00:01
* 6 FILTER
* 7 HASH JOIN OUTER 5029K 1635M 1568M 133K (1) 00:26:42
* 8 FILTER
* 9 HASH JOIN OUTER 5029K 1510M 235M 45724 (2) 00:09:09
* 10 FILTER
* 11 HASH JOIN RIGHT OUTER 846K 226M 7792K 23780 (2) 00:04:46
12 TABLE ACCESS FULL A9_MATRICULATIONFOLDER 185K 5613K 731 (2) 00:00:09
* 13 FILTER
* 14 HASH JOIN RIGHT OUTER 846K 201M 6784K 12190 (2) 00:02:27
15 TABLE ACCESS FULL A9_FORM06 192K 4517K 1340 (3) 00:00:17
* 16 FILTER
* 17 HASH JOIN RIGHT OUTER 65680 14M 2784K 9769 (2) 00:01:58
18 TABLE ACCESS FULL A9_FORM05 91913 1705K 592 (2) 00:00:08
* 19 HASH JOIN 65680 12M 8360 (2) 00:01:41
* 20 HASH JOIN 560 37520 25 (8) 00:00:01
* 21 HASH JOIN 560 14560 10 (10) 00:00:01
* 22 HASH JOIN 8 112 7 (15) 00:00:01
* 23 TABLE ACCESS FULL A9_PROFESSIONALORDER 6 30 3 (0) 00:00:01
* 24 TABLE ACCESS FULL A9_BRANCHOFFICE 16 144 3 (0) 00:00:01
25 TABLE ACCESS FULL A9_AGENT 1053 12636 3 (0) 00:00:01
* 26 TABLE ACCESS FULL A9_USER 2245 92045 14 (0) 00:00:01
* 27 TABLE ACCESS FULL A9_MATRICULATION 123K 16M 8333 (2) 00:01:41
28 TABLE ACCESS FULL A9_FORM576 899K 30M 8158 (2) 00:01:38
29 TABLE ACCESS FULL A9_IVTM 1207K 29M 7562 (3) 00:01:31
* 30 TABLE ACCESS FULL A9_VEHICLEDATA 979K 25M 9552 (1) 00:01:55
* 31 TABLE ACCESS FULL A9_VEHICLEOWNER 983K 44M 7771 (2) 00:01:34
Predicate Information (identified by operation id):
2 - access("VOWN"."MATRICULATION_ID"="MAT"."ID")
3 - access("MAT"."VEHICLEDATA_ID"="VD"."ID")
4 - access("MAT"."AGENCY_ID"="AY"."ID")
5 - filter("AY"."DELETEDON" IS NULL)
6 - filter("IVTM"."DELETEDON" IS NULL)
7 - access("MAT"."IVTM_ID"="IVTM"."ID"(+))
8 - filter("F576"."DELETEDON" IS NULL)
9 - access("MAT"."FORM576_ID"="F576"."ID"(+))
10 - filter("FO"."DELETEDON" IS NULL)
11 - access("MAT"."MATRICULATIONFOLDER_ID"="FO"."ID"(+))
13 - filter("F06"."DELETEDON" IS NULL)
14 - access("MAT"."FORM06_ID"="F06"."ID"(+))
16 - filter("F05"."DELETEDON" IS NULL)
17 - access("MAT"."FORM05_ID"="F05"."ID"(+))
19 - access("MAT"."AGENT_ID"="AG"."ID")
20 - access("AG"."ID"="US"."ID")
21 - access("AG"."BRANCHOFFICE_ID"="BO"."ID")
22 - access("BO"."PROFESSIONALORDER_ID"="PO"."ID")
23 - filter("PO"."DELETEDON" IS NULL)
24 - filter("BO"."DELETEDON" IS NULL)
26 - filter("US"."DELETEDON" IS NULL)
27 - filter("MAT"."VALID"=1 AND "MAT"."DELETEDON" IS NULL)
30 - filter("VD"."DELETEDON" IS NULL)
31 - filter("VOWN"."DELETEDON" IS NULL AND "VOWN"."MAINOWNER"=1)
2- Using SQL Profile
Plan hash value: 1408211821
Best regards,
dbajug
Edited by: dbajug on Aug 11, 2010 6:31 AM
Hi all,
the aswer is on this post:
Re: Explain plan
Regards,
dbajug
Similar Messages
-
1. How to create an explain plan with rowsource statistics for a complex query that include multiple table joins ?
When multiple tables are involved , and the actual number of rows returned is more than what the explain plan tells. How can I find out what change is needed in the stat plan ?
2. Does rowsource statistics gives some kind of understanding of Extended stats ?You can get Row Source Statistics only *after* the SQL has been executed. An Explain Plan midway cannot give you row source statistics.
To get row source statistics either set STATISTICS_LEVEL='ALL' in the session that executes theSQL OR use the Hint "gather_plan_statistics" in the SQL being executed.
Then use dbms_xplan.display_cursor
Hemant K Chitale -
How to change the explain plan for currently running query?
Hi All,
I am using Oracle enterprise 9i edition. I have a query which frames dynamically and running in the database. I noticed a table with 31147758 rows
in the query which has no indexes and taking more time to process. I tried to create an INdex on that table. I know the query is already running with a FULL table scan. Is it possible to change the explain plan for the current running query to consider the INDEX?
[code]
SELECT /*+ USE_HASH (c,e,b,a) */
d.att_fcc extrt_prod_dim_id,
d.att_fcc compr_prod_dim_id,
a.glbl_uniq_id glbl_uniq_id,
to_date(c.dit_code,'RRRRMMDD')STRT_DT,
(to_date(c.dit_code,'RRRRMMDD')+150)END_DT,
a.pat_nbr pat_id,
a.rxer_id rxer_id,
e.rxer_geog_id rxer_geog_id,
a.pharmy_id pharmy_id,
a.pscr_pack_id pscr_pack_id,
a.dspnsd_pack_id dspnsd_pack_id,
DENSE_RANK () OVER (PARTITION BY a.pat_nbr ORDER BY c.dit_code) daterank,
COUNT( DISTINCT d.att_fcc ) OVER (PARTITION BY a.pat_nbr, c.dit_code) event_cnt
DENSE_RANK () OVER (PARTITION BY a.pat_nbr,
d.att_fcc
ORDER BY c.dit_code) prodrank,
DENSE_RANK () OVER (PARTITION BY a.pat_nbr,
d.att_fcc
ORDER BY c.dit_code DESC) stoprank
FROM
pd_dimitems c,
pd_pack_attribs d ,
lrx_tmp_rxer_geog e,
lrx_tmp_pat_daterank p,
lrx_tmp_valid_fact_link a
WHERE c.dit_id = a.tm_id
AND e.rxer_id = a.rxer_id
AND a.glbl_uniq_id = p.glbl_uniq_id
AND p.daterank > 1
AND a.pscr_pack_id = d.att_dit_id
[/code]
The table lrx_tmp_pat_daterank is having that 31147758 rows. So I am wondering how to make the query to use the newly created index on the table?Why do you think using Indexes will improve the performance of the query? How many rows this query is returning? Optimizer might chose a Full table scan when it finds out that Index plan might not be useful. Why are you using /*+ USE_HASH (c,e,b,a) */ hint? This Hint will force oracle to use Full table scan instead of using the index. Try removing it and see if the plan changes.
Regards, -
Exactly how bad is this explain plan?
Hi,
I'm on Oracle 9i - 9.2.0.6.0.
First, please excuse my question, I'm not that good at reading explain plans.
I have this explain plan:
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)|
| 0 | SELECT STATEMENT | | 70057 | 20M| | 114K (12)|
|* 1 | FILTER | | | | | |
| 2 | TABLE ACCESS FULL | DUAL | 82 | | | 3 (34)|
|* 3 | INDEX RANGE SCAN | CHANGELOG_1 | 1 | 44 | | 2217 (3)|
| 4 | NESTED LOOPS OUTER | | 70057 | 20M| | 114K (12)|
| 5 | NESTED LOOPS OUTER | | 67062 | 18M| | 113K (11)|
| 6 | NESTED LOOPS OUTER | | 64194 | 16M| | 111K (10)|
| 7 | NESTED LOOPS OUTER | | 61450 | 14M| | 110K (9)|
| 8 | NESTED LOOPS OUTER | | 58823 | 13M| | 109K (8)|
| 9 | NESTED LOOPS OUTER | | 56308 | 12M| | 107K (6)|
| 10 | NESTED LOOPS OUTER | | 53900 | 11M| | 106K (5)|
| 11 | NESTED LOOPS OUTER | | 51596 | 10M| | 105K (4)|
| 12 | NESTED LOOPS OUTER | | 49390 | 9212K| | 104K (3)|
| 13 | NESTED LOOPS OUTER | | 47278 | 8310K| | 102K (2)|
|* 14 | HASH JOIN | | 31639 | 5067K| 4576K| 7331 (13)|
|* 15 | HASH JOIN | | 31639 | 4202K| 1936K| 1372 (9)|
| 16 | TABLE ACCESS FULL | COMPANY | 76111 | 1040K| | 335 (15)|
|* 17 | HASH JOIN | | 31649 | 3770K| | 933 (7)|
| 18 | TABLE ACCESS FULL | AGREEMENT | 149 | 3129 | | 3 (34)|
|* 19 | HASH JOIN | | 31649 | 3121K| | 928 (6)|
| 20 | TABLE ACCESS FULL | CONCRETEAGREEMENT | 34172 | 333K| | 55 (24)|
|* 21 | TABLE ACCESS BY INDEX ROWID| SPECIFICATION | 31649 | 2812K| | 866 (4)|
|* 22 | INDEX RANGE SCAN | SPECIFICATION_DATE | 37437 | | | 143 (5)|
| 23 | TABLE ACCESS FULL | PERSON | 1786K| 47M| | 4584 (11)|
|* 24 | TABLE ACCESS BY INDEX ROWID | INFORMATION | 1 | 16 | | 4 (25)|
|* 25 | INDEX RANGE SCAN | INFORMATION_SPECIFICATION | 2 | | | 3 (34)|
|* 26 | TABLE ACCESS BY INDEX ROWID | INFORMATION | 1 | 11 | | |
|* 27 | INDEX RANGE SCAN | INFORMATION_SPECIFICATION | 2 | | | 3 (34)|
|* 28 | TABLE ACCESS BY INDEX ROWID | INFORMATION | 1 | 14 | | |
|* 29 | INDEX RANGE SCAN | INFORMATION_SPECIFICATION | 2 | | | 3 (34)|
|* 30 | TABLE ACCESS BY INDEX ROWID | INFORMATION | 1 | 14 | | |
|* 31 | INDEX RANGE SCAN | INFORMATION_SPECIFICATION | 2 | | | 3 (34)|
|* 32 | TABLE ACCESS BY INDEX ROWID | INFORMATION | 1 | 11 | | |
|* 33 | INDEX RANGE SCAN | INFORMATION_SPECIFICATION | 2 | | | 3 (34)|
|* 34 | TABLE ACCESS BY INDEX ROWID | INFORMATION | 1 | 13 | | |
|* 35 | INDEX RANGE SCAN | INFORMATION_SPECIFICATION | 2 | | | 3 (34)|
|* 36 | TABLE ACCESS BY INDEX ROWID | INFORMATION | 1 | 12 | | |
|* 37 | INDEX RANGE SCAN | INFORMATION_SPECIFICATION | 2 | | | 3 (34)|
|* 38 | TABLE ACCESS BY INDEX ROWID | INFORMATION | 1 | 15 | | |
|* 39 | INDEX RANGE SCAN | INFORMATION_SPECIFICATION | 2 | | | 3 (34)|
|* 40 | TABLE ACCESS BY INDEX ROWID | INFORMATION | 1 | 17 | | |
|* 41 | INDEX RANGE SCAN | INFORMATION_SPECIFICATION | 2 | | | 3 (34)|
|* 42 | TABLE ACCESS BY INDEX ROWID | INFORMATION | 1 | 17 | | |
|* 43 | INDEX RANGE SCAN | INFORMATION_SPECIFICATION | 2 | | | 3 (34)|
--------------------------------------------------------------------------------------------------------------------- I can see that there are some FULL TABLE SCAN, but this may be OK. What worries me is the combination with numerous NESTED LOOPS.
A CTAS for approx 500.000 records out of 14.000.000 runs in about 180 mins. This is too much. My guess is that it should/could be brought down to something like 20 min.
For completeness, the query in question:
SELECT *
FROM stik_spec_inf_v
WHERE spdate >= to_date('15-03-2008', 'dd-mm-yyyy')
AND spdate < to_date('15-04-2008', 'dd-mm-yyyy');Wher eview is created as
CREATE OR REPLACE FORCE VIEW stik_spec_inf_v
AS
SELECT CAST(1 AS NUMBER(3)) dataversion
,sp.ID AS spid
,sp."DATE" AS spdate
,sp.valuedate
,sp.amount
,sp.amountcode
,sp.periodstart
,sp.periodend
,sp.ambcode
,sp.state AS spstate
,sp."TYPE" AS sptype
,sp.respitedate
,sp.stopcode
,sp.validcode
,sp.person
,sp.company
,sp.concreteagreement
,sp.reconciliation
,sp.partialscheme
,(SELECT 1
FROM dual
WHERE EXISTS(
SELECT 1
FROM changelog
WHERE targetclass = 'com.csc.jpay.voucher.Specification'
AND targetid = sp.ID)) spchanged
,i1.startdate AS daekgagedato
,i1.amount AS daekgage
,i2.startdate AS prmgagedato
,i2.amount AS prmgage
,i3.employerpercent
,i3.employeepercent
,i3.voluntarypercent
,i5.salaryperiod
,i6.groupcontractcode
,i7.workinghourspercent
,i9.startdate AS hiringdate
,i10.startdate AS resignationdate
,i21.policenumber
,ix."TYPE" AS leavecode
,ix.startdate AS leavestartdate
,ix.enddate AS leaveenddate
,pe.cpr
,pe.ksdid
,co.opkr_number
,a.NAME AS agreement_name
FROM SPECIFICATION sp
,information i1
,information i2
,information i3
,information i5
,information i6
,information i7
,information i9
,information i10
,information i21
,information ix
,person pe
,company co
,concreteagreement ca
,agreement a
WHERE 1 = 1
AND i1.SPECIFICATION(+) = sp.ID
AND i1."TYPE"(+) = 1
AND i2.SPECIFICATION(+) = sp.ID
AND i2."TYPE"(+) = 2
AND i3.SPECIFICATION(+) = sp.ID
AND i3."TYPE"(+) = 3
AND i5.SPECIFICATION(+) = sp.ID
AND i5."TYPE"(+) = 5
AND i6.SPECIFICATION(+) = sp.ID
AND i6."TYPE"(+) = 6
AND i7.SPECIFICATION(+) = sp.ID
AND i7."TYPE"(+) = 7
AND i9.SPECIFICATION(+) = sp.ID
AND i9."TYPE"(+) = 9
AND i10.SPECIFICATION(+) = sp.ID
AND i10."TYPE"(+) = 10
AND i21.SPECIFICATION(+) = sp.ID
AND i21."TYPE"(+) = 21
AND ix.SPECIFICATION(+) = sp.ID
AND ix."TYPE"(+) > 10
AND ix."TYPE"(+) < 21
AND pe.ID = sp.person
AND co.ID = sp.company
AND ca.ID = sp.concreteagreement
AND a.ID = ca.agreement;Please excuse my lengthy post. I still hope for some valuable input.
Thanks
PeterHi,
I have tried with an in-line view as John suggested. This give a FULL TABLE SCAN on information.
SELECT /*+ RULE */ * FROM (
SELECT sp.id spid, sp."DATE" spdate
FROM (SELECT SPECIFICATION
,max(decode("TYPE", 1, startdate)) daekgagedato
,max(decode("TYPE", 1, amount)) daekgage
,max(decode("TYPE", 2, startdate)) prmgagedato
,max(decode("TYPE", 2, amount)) prmgage
,max(decode("TYPE", 3, employerpercent)) employerpercent
,max(decode("TYPE", 3, employeepercent)) employeepercent
,max(decode("TYPE", 3, voluntarypercent)) voluntarypercent
,max(decode("TYPE", 5, salaryperiod)) salaryperiod
,max(decode("TYPE", 6, groupcontractcode)) groupcontractcode
,max(decode("TYPE", 7, workinghourspercent)) workinghourspercent
,max(decode("TYPE", 9, startdate)) hiringdate
,max(decode("TYPE", 10, startdate)) resignationdate
,max(decode("TYPE", 21, policenumber)) policenumber
,max(decode(sign("TYPE" - 10),1, decode(sign("TYPE" - 21), -1, "TYPE"))) leavecode
,max(decode(sign("TYPE" - 10),1, decode(sign("TYPE" - 21), -1, startdate))) leavestartdate
,max(decode(sign("TYPE" - 10),1, decode(sign("TYPE" - 21), -1, enddate))) leaveenddate
FROM information
WHERE TYPE BETWEEN 1 AND 21
GROUP BY SPECIFICATION) i
,SPECIFICATION sp
WHERE 1 = 1
AND sp.ID = i.SPECIFICATION)
WHERE spid = 1Any ideas on how to get around that?
Regards
Peter -
How i can obtain explain plan without run the query
Hello,
i need to know the result of explain of a query without run the query, it's this possible?
Thanks and best regards.explain plan for <your query>;
select * from table(dbms_xplan.display);Regards,
Rob. -
How to see my applecare plans?
I have an iMac, an iPad, and an iPhone with current Applecare plans. Whenever I log in to the website, none of these are listed, but if I call Applecare and say my name and "iPhone", they find it right away. They can't seem to find my iMac without its serial number though. Is there some specific web page I need to go to, to make sure that all the Applecare plans are in there and registered? I'm sure this is basic but I can't seem to figure out what Apple knows about and what it doesn't, and why.
thanks in advance,
MikeStart here:
https://selfsolve.apple.com/agreementWarrantyDynamic.do -
How can i paste the explain plan from toad..
Hello all
I tried taking a snap of the explain plan from toad but in this forum the paste option is disabled...please help964145 wrote:
I tried taking a snap of the explain plan from toad but in this forum the paste option is disabled...please helpI don't know, but it is a waste of time since explain plans from Toad are not useful.
Please read the forum FAQ on providing information for a tuning request, it describes how to generate an explain plan that can be shared.
{message:id=9360003}
This is an example.
SQL> explain plan for
2 select * from dual;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 3543395131
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 2 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS FULL| DUAL | 1 | 2 | 2 (0)| 00:00:01 |
-------------------------------------------------------------------------- -
Explain plan--Object not found error
Hi All,
I want to use 'explain plan' to optimise the query.
How do i see the explain plan in toad.
when i say
explain plan set statement_id='XX' for select stmt;
select * from explain plan
where statement_id='XX';
iam geeting object not found
what parameters i need to set up before using explain plan
Please give me details.
Please suggest.
Thanks.This should have been in TOAD Forum :-)).. Anyway,
You need to set the plan table name in view->Options->Oracle. If the specified plan table doesnt exist, create the plan table -
Explain plan for Query performance
Hi Gurus,
I need to improve the performance of a procedure. The procedure has the below QUery. I dont have Idea on how to imrpove the perf by seeing the explain plan. Can anyone please help me to explain where I need to change the code.
The below are the code and Explain plan for the same.
-----------Code----------------------------
SELECT IV_STORECODE AS STORECODE,
TO_CHAR(RD.ITEMCODE) AS ITEMCODE,
C.ITEMCATEGORYNAME,
ISUB.ITEMSUBCATEGORY1NAME
FROM RECEIPTS R
INNER JOIN RECEIPTDETAILS RD
ON R.RECEIPTID = RD.RECEIPTID
INNER JOIN ITEMCOMPANY IC
ON IC.ITEMCODE = RD.ITEMCODE
INNER JOIN ITEMCATEGORY C
ON IC.ITEMCATEGORY = C.ITEMCATEGORYID
LEFT OUTER JOIN ITEMSUBCATEGORY1 ISUB
ON ISUB.ITEMSUBCATEGORY1ID = IC.ITEMSUBCATEGORY1
AND ISUB.ITEMSUBCATEGORY1ID IN
(SELECT ITEMSUBCATEGORY1ID
FROM ITEMSUBCATEGORY1
WHERE ITEMCATEGORYID = IV_ITEMCATEGORY)
INNER JOIN STORE SE
ON SE.STORECODE = R.STORECODE
WHERE R.STORECODE = IV_STORECODE
AND SE.HOSPITALID = IV_HOSPITALID
AND TRUNC(R.CREATEDDATE) BETWEEN V_FROMDATE AND
V_TODATE
AND R.STATUSID NOT IN (99, 5)
AND
(IV_DRUGTYPE IS NULL OR
IC.DRUGTYPECATEGORYID = IV_DRUGTYPE)
UNION
SELECT IV_STORECODE AS STORECODE,
TO_CHAR(STD.ITEMCODE) AS ITEMCODE,
C.ITEMCATEGORYNAME,
ISUB.ITEMSUBCATEGORY1NAME
FROM STOCKTRANSACTION ST
INNER JOIN STOCKTRANSACTIONDETAILS STD
ON ST.STOCKTRANSACTIONID = STD.STOCKTRANSACTIONID
INNER JOIN ITEMCOMPANY IC
ON IC.ITEMCODE = STD.ITEMCODE
INNER JOIN ITEMCATEGORY C
ON IC.ITEMCATEGORY = C.ITEMCATEGORYID
LEFT OUTER JOIN ITEMSUBCATEGORY1 ISUB
ON ISUB.ITEMSUBCATEGORY1ID = IC.ITEMSUBCATEGORY1
AND ISUB.ITEMSUBCATEGORY1ID IN
(SELECT ITEMSUBCATEGORY1ID
FROM ITEMSUBCATEGORY1
WHERE ITEMCATEGORYID = IV_ITEMCATEGORY)
INNER JOIN STORE SE
ON SE.STORECODE = ST.STORECODE
WHERE ST.STORECODE = IV_STORECODE
AND SE.HOSPITALID = IV_HOSPITALID
AND TRUNC(ST.CREATEDDATE) BETWEEN V_FROMDATE AND
V_TODATE
AND ST.STATUS <> 99
AND STD.ITEMCODE NOT LIKE '%#%'
AND
(IV_DRUGTYPE IS NULL OR
IC.DRUGTYPECATEGORYID = IV_DRUGTYPE)
UNION
SELECT D.STORECODE,
TO_CHAR(D.ITEMCODE) AS ITEMCODE,
C.ITEMCATEGORYNAME,
ISUB.ITEMSUBCATEGORY1NAME
FROM DAILYINVENTORY D
INNER JOIN ITEMCOMPANY IC
ON IC.ITEMCODE = D.ITEMCODE
INNER JOIN ITEMCATEGORY C
ON IC.ITEMCATEGORY = C.ITEMCATEGORYID
LEFT OUTER JOIN ITEMSUBCATEGORY1 ISUB
ON ISUB.ITEMSUBCATEGORY1ID = IC.ITEMSUBCATEGORY1
AND ISUB.ITEMSUBCATEGORY1ID IN
(SELECT ITEMSUBCATEGORY1ID
FROM ITEMSUBCATEGORY1
WHERE ITEMCATEGORYID = IV_ITEMCATEGORY)
INNER JOIN STORE SE
ON SE.STORECODE = D.STORECODE
WHERE D.STORECODE = IV_STORECODE
AND SE.HOSPITALID = IV_HOSPITALID
AND TRUNC(D.UPDATEDDATE) <= V_TODATE
AND D.QTY > 0
AND D.ITEMCODE NOT LIKE '%#%'
AND C.ITEMCATEGORYID = IV_ITEMCATEGORY
AND (IV_DRUGTYPE IS NULL OR
IC.DRUGTYPECATEGORYID = IV_DRUGTYPE)
AND (IV_SUBITEMCATEGORY IS NULL OR
ISUB.ITEMSUBCATEGORY1ID = IV_SUBITEMCATEGORY) Will post the explain plan ..
Thanks in advance..Ensure you also include all the other information people will need to help you, e.g. database version, table structures/relationships and cardinalities, row counts etc.
See the two threads linked to in the FAQ: {message:id=9360003} -
Dear All,
Please let me know how to publish my explain plan output properly here. Earlier i used [code] ..... [/code]
Thanks,
KodsWho knows?
Are you just looking at random explain plans to find a problem?
Or did you look at the explain plan for a specific performance problem?
Please format code and explain plan output with code tags.
See also this thread, How to post a SQL tuning request:
HOW TO: Post a SQL statement tuning request - template posting
At the end of the day are the row estimates accurate?
If they are, then everything's probably ok.
If not, then everything might be ok or it might not be.
Merge Join Cartesian + Buffer Sort operations are often, but not always, an indication of a problem particularly when the associated estimates are inaccurate for whatever reason. -
Explain plans - caching question
I am trying to get some explain plan information for some queries that we have running poorly. Our application uses some alter session statements to set the optimizer_mode to all_rows. I am trying to determine if we need to include the optimizer_index_cost_adj parameter and possibly the optimizer_index_caching parameter.
Using SQL Developer I can easily run the different alter session statements needed and then get an explain plan for the query in question. However I am seeing some weird results - for example long query times for queries that have a relatively low cost. On the flip side I am seeing some queries that have a higher cost return quicker.
I am doing this many times over and am wondering what impact using the same query could have. Is this query being cached in Oracle? To get an accurate explain plan would I need to clear a cache each time?
Also, in the explain plan is the cost figure the most important? How is it that a query can have a low cost and take longer to complete than the same query with a higher cost and some different parameters?There are no fixed road map for what to see in explain plan,but some common observation should be made for explain plan i.e full table scans due to poor use of indexing,inappropriate hints uses for forcing indexing where FTS can be faster.unnecessary sorting,cartesian
joins, outer joins, and anti-joins.
At last i would say that every database vary to its different hardware platforms and those hardware have different configuration,these things can effect oracle optimizer.
So, if my statistics are current, what should I be
taking out of the explain plan? I always assumed
cost was the main indicator of the performance of a
query.As justin already told cost is not something which should be considered for tuning query rather access path, but there is more other then explain plan access path e.g TKPROF tool which will address you plan as well as others stuff which should be considered for tuning query.
http://download.oracle.com/docs/cd/B10501_01/server.920/a96533/sqltrace.htmKhurram -
I am trying to use TOAD to find the query performance. When I clicked on explain plan tab i get an error message: ORA-02404: specified plan table not found.
Can some one please tell me how to proceed from here so that I can check the explain plan for this tableI don't know how TOAD works with EXPLAIN PLAN, but mybe it is if you have PLAN_TABLE created in your database and granted all on it to public.
SQL> @<ORACLE_HOME>/rdbms/admin/utlxplan.sql
SQL> create public synonym plan_table for plan_table
SQL> grant all on plan_table to public
I don't know if you're looking for somethinkg like that ... -
Explain Plan in SQL Developer 1.5.1
How do I run Explain Plan against a Stored Package using SQL Developer 1.5.1?
I'm not familiar with this tool and need to examine a specific package.
Thanks.AFAIK, you can only get an explain plan for SQL statements, not PL/SQL code...
K. -
Explain Plan in Pl/SQL developer tool
How to get the explain plan result of a query in PL/SQL developer tool which has a database link ?
Also, please suggest the min and max Cost, Cardinality and byte values
Thanks859486 wrote:
How to get the explain plan result of a query in PL/SQL developer tool which has a database link ?PL/SQL Developer is a tool written by allround automations.
I suggest you ask how to use that tool vie the support option on their own website/forums:
http://www.allroundautomations.com/plsqldev.html
Also, please suggest the min and max Cost, Cardinality and byte valuesmin cost would be 0
max cost could be anything
cardinality is http://en.wikipedia.org/wiki/Cardinality_%28SQL_statements%29
bytes are the number of estimated bytes involved in the data retrieved/processed. -
Explain plan, slow update
We have two schemes in our database. One general and one history. When record in general scheme is modified trigger updates record in history scheme and inserts one new row in history scheme. There are indexes on columns that are used in updates(where part :)) and as i can see(using explain plan for) indexes are used. Problem is that when client application fires update it takes too long(6 sec) to be executed. Actually there is very strange behavior, it executes 5 updates in one second then next one takes 6 seconds. Tables have only around 1000 rows. Is there any way to see whole explain plan including trigger execution, when i issue exp plan for update of general scheme i get only exp plan for update - there are no informations about trigger. Also if anybody has some advice I am more than willing to hear :)
You might want to consider enabling a SQL Trace via DBMS_MONITOR for more recent versions or setting the SQL_TRACE parameter in past versions. Once you have the output you can use TKPROF. Once you have the TKPROF report you can try and find the queries that are taking the most time to execute.
Hope that helps!
Maybe you are looking for
-
How to export output to Excel (or file that can be opened by excel).
Hi, Have just installed SQL Developer. Have entered an SQL statement and Executed the Statement. Now I want to save the result in Excel. But I cannot find a way to save the result. When I choose to save I only save the SQL statement. Please advise. T
-
How do i reveal file names of clips in event library for imovie 11?
i recently began a new project in imovie 11 and i imported many clips into a new event i created. many clips look the same and i cannot seem to find a way to reveal the file names of each clip so i can distinguish between them. Is there a way to reve
-
Mobile Care app/ Software update always pops up with power on
I am guessing that this is the application Verizon uses to deliver updates to the phone? Every time I power up the phone, I get a software update screen telling me it is going to download an update, which it never actually seems to do. It's pretty i
-
Bro-in-law wiped HDD and tried to load XP Pro. Didn't work, no drivers. I ordered retore disks. Tried Toshiba Recovery Wizard. Got Toshiba Recovery Wizard <Error> An error has occurred. ERROR: 03-EEEE-0000 An error has occurred. Please press [OK] to
-
Hello All, I've created a kick-*** infographic in Illustrator using 3D Extrude. Trouble is, the damn thing won't export properly. Here's what it looks like on the screen: This is what it looks like when I export it as a PNG, JPG, TIFF, whatever: As y