what code is better-how reading explain plan

10g. How to read explain plan
explain plan for
with av as
(
SELECT  last_name, salary, 
        department_id,
          round(avg(salary) over (partition by department_id) ) avg_sal
FROM    employees
)

select * from av where salary > avg_sal
order by last_name;

select * from table(dbms_xplan.display)
 
explain plan

Plan hash value: 1582291400
 
----------------------------------------------------------------------------------
| Id  | Operation            | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------------
|   0 | SELECT STATEMENT     |           |   107 |  5671 |     5  (40)| 00:00:01 |
|   1 |  SORT ORDER BY       |           |   107 |  5671 |     5  (40)| 00:00:01 |
|*  2 |   VIEW               |           |   107 |  5671 |     4  (25)| 00:00:01 |
|   3 |    WINDOW SORT       |           |   107 |  1605 |     4  (25)| 00:00:01 |
|   4 |     TABLE ACCESS FULL| EMPLOYEES |   107 |  1605 |     3   (0)| 00:00:01 |
----------------------------------------------------------------------------------
 
Predicate Information (identified by operation id):
---------------------------------------------------
 
   2 - filter("SALARY">"AVG_SAL")
explain plan for

SELECT  a.last_name, a.salary, 
        a.department_id, b.salavg
FROM    employees a, (SELECT   department_id, 
                      AVG(salary) salavg
                      FROM     employees
                      GROUP BY department_id) b
WHERE   a.department_id = b.department_id
AND     a.salary > b.salavg
order by last_name

select * from table(dbms_xplan.display)
Plan hash value: 802276651
 
----------------------------------------------------------------------------------
| Id  | Operation            | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------------
|   0 | SELECT STATEMENT     |           |   165 |  5610 |     8  (25)| 00:00:01 |
|*  1 |  FILTER              |           |       |       |            |          |
|   2 |   SORT GROUP BY      |           |   165 |  5610 |     8  (25)| 00:00:01 |
|*  3 |    HASH JOIN         |           |  3296 |   109K|     7  (15)| 00:00:01 |
|   4 |     TABLE ACCESS FULL| EMPLOYEES |   107 |  2889 |     3   (0)| 00:00:01 |
|   5 |     TABLE ACCESS FULL| EMPLOYEES |   107 |   749 |     3   (0)| 00:00:01 |
----------------------------------------------------------------------------------
 
Predicate Information (identified by operation id):
---------------------------------------------------
 
   1 - filter("A"."SALARY">SUM("SALARY")/COUNT("SALARY"))
   3 - access("A"."DEPARTMENT_ID"="DEPARTMENT_ID")

Rahul India wrote:

----------------------------------------------------------------------------------
| Id  | Operation            | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------------
|   0 | SELECT STATEMENT     |           |   107 |  5671 |     5  (40)| 00:00:01 |
|   1 |  SORT ORDER BY       |           |   107 |  5671 |     5  (40)| 00:00:01 |
|*  2 |   VIEW               |           |   107 |  5671 |     4  (25)| 00:00:01 |
|   3 |    WINDOW SORT       |           |   107 |  1605 |     4  (25)| 00:00:01 |
|   4 |     TABLE ACCESS FULL| EMPLOYEES |   107 |  1605 |     3   (0)| 00:00:01 |
----------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("SALARY">"AVG_SAL")

----------------------------------------------------------------------------------
| ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
----------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | 165. 5610 | 8 (25) | 00:00:01 |
|* 1 | FILTER |
| 2. GROUP SORT BY | 165. 5610 | 8 (25) | 00:00:01 |
|* 3 | HASH JOIN | 3296. 109K | 7 (15) | 00:00:01 |
| 4. TABLE ACCESS FULL | EMPLOYEES | 107. 2889 | 3 (0) | 00:00:01 |
| 5. TABLE ACCESS FULL | EMPLOYEES | 107. 749. 3 (0) | 00:00:01 |
----------------------------------------------------------------------------------

Information of predicates (identified by the operation identity card):
---------------------------------------------------
1 - filter("A".") SALARY "> SUM ("SALARY") COUNT ("SALARY"))"
3 - access("A".") DEPARTMENT_ID "=" DEPARTMENT_ID")

As a general rule, there is no way, you can decide which is the best plan without knowing what data happens in the request, and what will come out.
You will notice, among other things, that Oracle has used a view complex merger to change your query with the aggragate inline view in a simple join with aggregation end (see http://jonathanlewis.wordpress.com/2007/03/08/transformation-and-optimisation/ for invasive how it may be). With a different dataset the optimizer might decide to regroup before joining - just the way you wrote the application.

An essential difference between your two plans is (as others have pointed out) that one of them analyse the table twice, the other once - however, the other key difference is that the whole dataset COULD BE relevant to be sorted by the analytical application and resources used in the genre could well take on the resources used by a second analysis and integration of a single column.

The difference is irrelevant in this case - but the difference exists and must be considered in the greatest examples.

You could also write the query to use a subquery to correlated - which the optimizer may rewrite the same plan 'join then aggregate' one of your queries achieved - but once again as an intelligent agent, you can decide that (in some cases), the best plan is the subquery filter implied by the form of the SQL.

Concerning
Jonathan Lewis

Tags: Database

Similar Questions

  • I can't reactivate my e-reader with my existing Adobe ID and password which are both correct. I alwayss get the message "the server activation Code error: E_AUTH_NOT_READY" what kind of problem is this and what is more important, how can I resolve it quic

    I can't reactivate my e-reader with my existing Adobe ID and password which are both correct. I alwayss get the message "the server activation Code error: E_AUTH_NOT_READY" what kind of problem is this and what is more important, how can I resolve it quickly. I'm on vacation and you want to read. Thanks for the quick response.

    Yes, actually I talk about digital editions. Do you know how to solve the problem, as stated in my first mail of Digital Editions? Thank you for your kind cooperation.

  • Windows FixIt error code 0 x 80092003. -What this means and how can I solve this problem?

    I have a PC with Windows XP SP3... ecentlped recognizing my DVD/CDRW. I tried to download Windows Fixit and when I tried to run, I get the error code 0 x 80092003. -What this means and how can I solve this problem?

    HP Pavilion a1410n PC with Windows XP Media Center edition. Sony Optiarc cddvdRW.

    Hi J Mbanza,

    -What is the link that you used to download the fix tool from?

    error 0 x 80092003 which is an error reading or writing to a file.

    Try to download from the link below and check.

    Your CD or DVD drive cannot read or write media - A Mr Fixit
    http://support.Microsoft.com/GP/cd_dvd_drive_problems

    Thank you!

  • I bought the software Acrobat reader pro plan, but I am still unable to protect my files? How can I protect my files when tools only allows me to add them?

    I bought the software Acrobat reader pro plan, but I am still unable to protect my files? How can I protect my files when tools only allows me to add them?

    Hi yaritzab46986362,

    If you purchased a plan from Pro to Adobe Acrobat Pro DC, you need to use to protect the files.

    I guess what you have opened is Adobe Acrobat Reader DC which is a free application to view and print PDF files.

    If If Acrobat Pro DC is not installed on your machine, you can download it here: Download Adobe Acrobat products. Standard, Pro | DC, XI, X

    Thank you

    Abhishek

  • How to explain the following code?

    How to explain the following code?
    1 set setOpenTradeIds = mapTrades.keySet (filter);
    2 map mapResults = null agent, map.invokeAll ((Filter));
    Is defined a class and setOPenTradeIds a new object?
    Is card calss and mapResults a new object?

    Thank you

    Published by: frank.qian on June 7, 2009 10:48

    Hi Frank,.

    Is mapTrades an object and a set of keys one of its methods?

    mapTrade is a reference variable refers to an instance of a class that implements the keySet() method that returns a reference to an instance of a class that implements the interface of game

    What is map.invokeAll? Where to get the information about it?

    map is a reference variable refers to an instance of a class that implements the invokeAll() method that returns a reference to an instance of a class that implements the map interface In case of card to make reference to an instance of a class that implements the InvocableMap interface, you can find consistency documentation 3.4.2 method to InvocableMap.

    Kind regards

    Harv

  • When you drag the file on the external drive I get the error code-43? What it means? How to fix? Thank you!

    When you drag the file on the external drive I get the error code-43? What it means? How to fix? Thank you!

    Restart the computer and try again.

  • get the error code 66A message, what to do and how to fix it?

    get the error code 66A message, what to do and how to fix it?

    Hello

    see if that helps to fix:

    How to reset the Windows Update components?

    There is also an automatic 'fix - it' here

    http://support.Microsoft.com/kb/971058

    Also, try to put the KB numbers in the search on the link below and then manually download the

    http://www.Microsoft.com/downloads/en/default.aspx

    or repost in the correct windows update forum

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_vista-windows_update?page=1&tab=all

  • Error code: 0x80070426. -What this means and how can it be solved?

    I have Dell laptop and I'm having a difficult time with a lot of things about Microsoft. I keep trying Windows Update 10 and it won't let me. I also tried to install applications or games store, and every time I put in my Microsoft account, it says

    "Something happened and your purchase could not be completed. "Error code: 0x80070426.

    I got this error again when I tried to change my Microsoft account and he said

    "We're sorry, but something went wrong. Your account has not been changed to this account from Microsoft. "Code: 0x80070426.

    Ive tried to do a new account of Microsoft and everything but nothing works and I don't know if it's making my computer and does not allow upgrade to Windows 10. Ive restarted, it, did a factory reset, wiped out all of the computer and still no luck.

    I guess my main question is: what is this error code 0x80070426 and how can I solve this problem?

    After that, how can I go do the update of Windows 10 completely rather than go through the whole process just to have a window pop up after a half hour saying 'Windows 10 update could not be completed.

    Hello

    You could try to create media to win 10 since a different website...

    Then just run Windows...

    You can try to install from the site... it does not require a Microsoft Account...

    If you are creating media, you have it and not need to mess with downloading more...

    http://www.Microsoft.com/en-us/software-download/Windows10

  • When I open a PDF and try and connect you to convert the document to word format he said "reader has no ability to access this service" and it doesn't let me move forward. What this means and how do I continue to Word so I can edit pdf

    When I open a PDF and try and connect you to convert the document to word format he said "reader has no ability to access this service" and it doesn't let me move forward. -What this means and how do I continue to Word so I can change the pdf document?

    Hi wayned76005641,

    You subscription Adobe export to PDF, make sure that you are signed in DC from Adobe Acrobat Reader Adobe - Adobe Acrobat Reader DC Distribution using your Adobe ID to use the service to export it to PDF service The Adobe export in PDF format allows you to convert a PDF to Word, Excel, PowerPoint and RTF formats..

    You can also use this online https://cloud.acrobat.com/exportpdf service

    Once the PDF is converted .docx file you can edit in MS Word.

    Kind regards
    Nicos

  • I get charged $74.95 per month for the creative cloud. I am trying to cancel it, but according to my adobe account info, I'm not on a plan. How is what happens? And how can I stop Adobe to credit my credit card each month?

    I get charged $74.95 per month for the creative cloud. I am trying to cancel it, but according to my adobe account info, I'm not on a plan. How is what happens? And how can I stop Adobe to credit my credit card each month?

    Kindly Contact customer you can also try: phone support | Orders, returns of trade.

    Let us know if you need assistance with this.

    Atul_Saini

  • I upgraded my windows and I want to restore Adobe Reader XI (I think that's what I paid). How can I put this back on my computer?

    I upgraded my windows and I want to restore Adobe Reader XI (I think that's what I paid). How can I put this back on my computer?

    The reader is free, so I hope that you don't worry about it. You can download and install from here: http://get.adobe.com/reader/

  • I get a box with internet script error explore - google.search error ' customSearchControl is null or not an object - code o - what is it and how do I fix?

    I get a box when get on google home page - script error Internet explorer

    CAR1

    Google error

    'customSearchControl' is null or not an object

    Code0

    What it means and how to fix it?

    You might want to think twice before you reset your unspecified version of IE...

    This from Microsoft KB923737:

    When you reset Internet Explorer settings, all modules and customizations are removed, and basically, you start with a new version of Internet Explorer.

    The feature reset the Internet Explorer settings restores the following elements to their default settings:

    • Home pages
    • Search scopes
    • Browsing history
    • Form data
    • Passwords
    • Appearance settings
    • Toolbars
    • ActiveX controls

    In addition, the feature reset the settings of Internet Explorer disables all add-ins.

    This is what will happen if you choose to reset your IE - what do you want?

    If you receive script debugging messages, which usually means that IE is not happy with the web page, because the web page has some mistakes in there, then you may want see if this article applies to you instead of just beating a first all your Internet Explorer settings:

    http://support.Microsoft.com/kb/822521

  • How to keep the formatting explain plan made on this forum

    Can you please tell me as a way to preserve the formatting of explain plan made on this forum. I tried to use the '-' tag, but failed.

    \

    PLAN_TABLE_OUTPUT

    --------------------------------------------------------------------------------

    Hash value of plan: 615168685

    ---------------------------------------------------------------------------

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

    ---------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |      |    23.  1242.     7 (15) | 00:00:01 |

    |*  1 |  HASH JOIN |      |    23.  1242.     7 (15) | 00:00:01 |

    |   2.   TABLE ACCESS FULL | DEPT |    13.   234.     3 (0) | 00:00:01 |

    |   3.   TABLE ACCESS FULL | EMP |    23.   828 |     3 (0) | 00:00:01 |

    ---------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    1 - access("E".") DEPTNO "=" D ". ("' DEPTNO ')

    15 selected lines.

    \

    Go to advanced editor and change the font to a fixed-width font e.g. Courier New

    PLAN_TABLE_OUTPUT

    --------------------------------------------------------------------------------

    Hash value of plan: 615168685

    ---------------------------------------------------------------------------

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

    ---------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |      |    23.  1242.     7 (15) | 00:00:01 |

    |*  1 |  HASH JOIN |      |    23.  1242.     7 (15) | 00:00:01 |

    |   2.   TABLE ACCESS FULL | DEPT |    13.   234.     3 (0) | 00:00:01 |

    |   3.   TABLE ACCESS FULL | EMP |    23.   828 |     3 (0) | 00:00:01 |

    ---------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    1 - access("E".") DEPTNO "=" D ". ("' DEPTNO ')

    15 selected lines.

  • DECODE is changing the explain plan

    I have a statement with a decoding function in the where clause like this:
    AND decode(:cropcode,-1,'-1',sdu.u_crop_group) = decode(:cropcode,-1,'-1',:cropcode)
    When I have a package-1 as parameter for cropgroup the filter would result by ' AND '-1' = '-1', and the statement is executed in less than 2 seconds.»»» When I leave this where clause it takes almost 18 seconds. The result is the same so I don't understand why the explain plan command is so different and why not use index scans in the statement without decoding.

    Below plans to explain and tkprofs to 1 (no decode) and 2 (decode).

    * explain 1 *.
    {code}
    SQL statement that produced these data:
    Select * from table (dbms_xplan.display)

    PLAN_TABLE_OUTPUT

    ---------------------------------------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | TempSpc | Cost (% CPU).
    ---------------------------------------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | 7080 | 2413K | 43611 (2) |
    | 1. SORT ORDER BY | 7080 | 2413K | 5224K | 43611 (2) |
    |* 2 | FILTER |
    |* 3 | HASH JOIN | 7156. 2 438 K | 43075 (2) |
    | 4. TABLE ACCESS FULL | DWH_ABS_DETERMINATION | 17745. 363KO | 83 (0) |
    |* 5 | OUTER HASH JOIN | 7156. 2292K | 42991 (2) |
    |* 6 | HASH JOIN | 7156. 1355K | 42907 (2) |
    |* 7 | HASH JOIN | 6987. 1187K | 19170 (2) |
    |* 8 | HASH JOIN | 6947 | 963K | 10376 (1) |
    |* 9 | TABLE ACCESS BY INDEX ROWID | ALIQUOT | 3. 144. 3 (0) |
    | 10. NESTED LOOPS | 6907. 897K | 8577 (1) |
    | * 11 | HASH JOIN | 2264 | 187K | 1782 (2) |
    | 12. TABLE ACCESS BY INDEX ROWID | SAMPLE | 190. 4370. 17 (0) |
    | 13. NESTED LOOPS | 2264 | 152K | 107 (1) |
    | 14. NESTED LOOPS | 12. 552. 25 (0) |
    | * 15 | TABLE ACCESS FULL | SDG_USER | 12. 288. 13 (0) |
    | 16. TABLE ACCESS BY INDEX ROWID | SDG | 1. 22. 1 (0) |
    | * 17. INDEX UNIQUE SCAN | PK_SDG | 1 | | | 0 (0) |
    | * 18. INDEX RANGE SCAN | FK_SAMPLE_SDG | 597. 2 (0) |
    | 19. TABLE ACCESS FULL | SAMPLE_USER | 1078K | 16 M | 1669 (1) |
    | * 20. INDEX RANGE SCAN | FK_ALIQUOT_SAMPLE | 3 | | | 2 (0) |
    | 21. TABLE ACCESS FULL | ALIQUOT_USER | 3403K | 29 M | 1781 (3) |
    | 22. TABLE ACCESS FULL | TEST | 3423K | 104 M | 8775 (2) |
    | * 23. TABLE ACCESS FULL | RESULT | 3435K | 65 M | 23718 (2) |
    | 24. VIEW | PLATE | 21787 | 2851K | 84 (2).
    | * 25. FILTER |
    | 26. TABLE ACCESS FULL | PLATE | 21787 | 574K | 84 (2).
    | * 27. INDEX UNIQUE SCAN | PK_OPERATOR_GROUP | 1. 7 | | 0 (0) |
    | * 28. INDEX UNIQUE SCAN | PK_OPERATOR_GROUP | 1. 7 | | 0 (0) |
    | * 29. INDEX UNIQUE SCAN | PK_OPERATOR_GROUP | 1. 7 | | 0 (0) |
    | * 30 | INDEX UNIQUE SCAN | PK_OPERATOR_GROUP | 1. 7 | | 0 (0) |
    | * 31. INDEX UNIQUE SCAN | PK_OPERATOR_GROUP | 1. 7 | | 0 (0) |
    ---------------------------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    2. ((«GROUP_ID» EST NULL ou EXISTE (SELECT / * + * / 0 DE "AGIL".) filter)) "OPERATOR_GROUP"
    "OPERATOR_GROUP' WHERE ' OPERATOR_ID"="LIMS$ OPERATOR_ID" () AND "GROUP_ID" =:B1)) AND ('GROUP_ID' IS NULL) "'". "
    OR EXISTS (SELECT / * + * / 0 "LIMS".) ' ' OPERATOR_GROUP ' 'OPERATOR_GROUP' WHERE
    "OPERATOR_ID"="LIMS$ OPERATOR_ID" () AND "GROUP_ID" =:B2)) AND ('GROUP_ID' IS NULL OR EXISTS (SELECT / * +)) "" "."
    * / 0 "LIMS". "' OPERATOR_GROUP ' 'OPERATOR_GROUP' WHERE ' OPERATOR_ID"="LIMS$ OPERATOR_ID" () AND "."
    (('GROUP_ID' =: B3)) AND ('GROUP_ID' IS NULL OR EXISTS (SELECT / * + * / 0 "LIMS".)) "" OPERATOR_GROUP ".
    'OPERATOR_GROUP' WHERE ' OPERATOR_ID "=" LIMS$ OPERATOR_ID "() AND"GROUP_ID "=:B4)))".
    3 - access ("U_ABS_DETERMINATION" ="DETERMINATION_ASSIGNMENT")
    5 - access("PLT".") PLATE_ID"(+) ="PLATE_ID")
    6 - access ("TEST_ID" ="TEST_ID")
    7 - access ("ALIQUOT_ID" ="ALIQUOT_ID")
    8 - access ("ALIQUOT_ID" ="ALIQUOT_ID")
    9 - filter("STATUS"='C' OR "STATUS"='P' OR "STATUS"='V')
    11 - access ("SAMPLE_ID" ="SAMPLE_ID")
    15 - filter ("U_ABS_DETERMINATION" IS NOT NULL AND "U_CLIENT_TYPE" = 'QC' AND
    "U_WEEK_OF_PROCESSING"= TO_NUMBER(:WEEK) AND "U_YEAR_OF_SAMPLE_DELIVERY' = TO_NUMBER (:YEAR)).
    17 - access ("SDG_ID" ="SDG_ID")
    18 - access ("SDG_ID" ="SDG_ID")
    20 - access ("SAMPLE_ID" ="SAMPLE_ID")
    23 - filter ('NAME' = 'End result')
    25 - filter("GROUP_ID" IS NULL OR EXISTS (SELECT /*+ */ 0 FROM "LIMS".")) OPERATOR_GROUP ".
    'OPERATOR_GROUP' WHERE ' OPERATOR_ID "=" LIMS$ OPERATOR_ID "() AND"GROUP_ID "=:B1))".
    27 - access ("GROUP_ID" =: B1 AND "OPERATOR_ID"="LIMS$ OPERATOR_ID" ())
    28 - access ("GROUP_ID" =: B1 AND "OPERATOR_ID"="LIMS$ OPERATOR_ID" ())
    29 - access ("GROUP_ID" =: B1 AND "OPERATOR_ID"="LIMS$ OPERATOR_ID" ())
    30 - access ("GROUP_ID" =: B1 AND "OPERATOR_ID"="LIMS$ OPERATOR_ID" ())
    31 - access ("GROUP_ID" =: B1 AND "OPERATOR_ID"="LIMS$ OPERATOR_ID" ())

    Note
    -----
    -"PLAN_TABLE' is old version
    {code}


    * tkprof 1 *.
    {code}

    TKPROF: Release 10.2.0.3.0 - Production on Tue Jan 13 13:21:47 2009

    Copyright (c) 1982, 2005, Oracle. All rights reserved.

    Trace file: C:\oracle\product\10.2.0\admin\nautp02\udump\nautp02_ora_880.trc
    Sorting options: by default

    ********************************************************************************
    Count = number of times OIC procedure has been executed
    CPU = time in seconds cpu execution
    elapsed = elapsed time in seconds the execution
    disc = number of physical reads from disk buffers
    Query = number of buffers for a consistent reading
    current = number of buffers in current mode (usually for the update)
    rows = number of rows processed by extracting or execute the call
    ********************************************************************************

    SELECT sdu.u_crop_group,
    SD. Name as sdg_name,
    ad.variety_name,
    ad.batch_number,
    B.SID as aliquot_name,
    Sau.u_box_code as box_code,
    Sau.u_box_position as box_position,
    t.Nom as test_name,
    r.original_result,
    PLT. Name as plate_name,
    Concat (chr (a.plate_row + 64), a.plate_column) as plate_position,
    au.u_replicate_number as replicate_number
    OF lims_sys.sdg sd,.
    lims_sys.sdg_user STO,
    lims_sys. Sample his.
    lims_sys.sample_user sau,
    lims_sys.aliquot has,
    to the lims_sys.aliquot_user,.
    lims_sys.test t,
    lims_sys. Result r,
    PLT lims_sys.plate,
    Ad lims_sys.abs_determination
    WHERE sd.sdg_id = sdu.sdg_id
    AND sd.sdg_id = sa.sdg_id
    AND sa.sample_id = sau.sample_id
    AND sau.sample_id = a.sample_id
    AND a.aliquot_id = au.aliquot_id
    AND au.aliquot_id = t.aliquot_id
    AND t.test_id = r.test_id
    AND plt.plate_id (+) = a.plate_id
    AND sdu.u_abs_determination = ad.determination_assignment
    AND a.status IN ('V', 'P', 'C')
    AND r.name = 'result '.
    AND sdu.u_client_type = "QC".
    AND sdu.u_year_of_sample_delivery = (: year)
    AND sdu.u_week_of_processing = (: week)
    - AND decode(:cropcode,-1,'-1',sdu.u_crop_group) = decode(:cropcode,-1,'-1',:cropcode)
    ORDER BY box_code, box_position, replicate_number

    call the query of disc elapsed to cpu count current lines
    ------- ------ -------- ---------- ---------- ---------- ---------- ----------
    Parse 1 0.00 0.00 0 0 0 0
    Run 1 1.15 1.16 0 0 0 0
    Fetch 1 8.53 16.10 227649 241266 0 500
    ------- ------ -------- ---------- ---------- ---------- ---------- ----------
    Total 3 9.68 17,27 227649 241266 0 500

    Chess in the library during parsing cache: 1
    Lack in the library during execution cache: 1
    Optimizer mode: ALL_ROWS
    The analysis of the user id: 97

    Rows Row Source operation
    ------- ---------------------------------------------------
    SORT ORDER BY 500 (cr = 241266 pr = 227649 pw = time 0 = 16104631 en)
    FILTER 21311 (cr = 241266 pr = 227649 pw = time 0 = 16246749 en)
    21311 HASH JOIN (cr = 241266 pr = 227649 pw = time 0 = 16225434 en)
    17745 TABLE ACCESS FULL DWH_ABS_DETERMINATION (cr = 374 pr = 0 pw = time 0 = 69 fr)
    21311 HASH JOIN RIGHT OUTER (cr = 240892 pr = 227649 pw = time 0 = 16170607 en)
    21895 VIEW PLATE (cr = 316 pr = 0 pw = time 0 = 43825 US)
    21895 FILTER (cr = 316 pr = 0 pw = time 0 = 43823 US)
    21895 TRAY FULL ACCESS (cr = 316 pr = 0 pw = time 0 = 31 US)
    0 INDEX UNIQUE SCAN PK_OPERATOR_GROUP (cr = 0 pr = 0 pw = time 0 = 0 US)(object id 45769)
    21311 HASH JOIN (cr = 240576 pr = 227649 pw = time 0 = 16106174 en)
    21311 HASH JOIN (cr = 133559 pr 121596 pw = time = 0 = 9594130 en)
    21311 HASH JOIN (cr = 94323 pr = 83281 pw = time 0 = 6917067 en)
    21311 HASH JOIN (cr = 86383 pr 75547 pw = time = 0 = 5509672 en)
    JOIN by HASH 7776 (cr = 8134 pr = 0 pw = time 0 = 285364 en)
    TABLE ACCESS BY INDEX ROWID SAMPLE 7776 (cr = 572 pr = 0 pw = time 0 = 27152 US)
    7876 NESTED LOOPS (cr = 377 pr = 0 pw = time 0 = 488287 en)
    JOIN by HASH 99 (cr = 160 pr = 0 pw = time 0 = US 4168)
    99 TABLE ACCESS FULL SDG_USER (cr = 53 pr = 0 pw = time 0 = US 1209)
    5719 TABLE ACCESS FULL SDG (cr = 107 pr = 0 pw = time 0 = 17 US)
    7776 INDEX RANGE SCAN FK_SAMPLE_SDG (cr = 217 pr = 0 pw = time 0 = 623 en)(object id 45990)
    1079741 TABLE ACCESS FULL SAMPLE_USER (cr = 7562 pr = 0 pw = time 0 = 24 US)
    3307948 TABLE ALIQUOT FULL ACCESS (cr = 78249 pr = pw 75547 time = 0 = 3331129 en)
    3406836 TABLE ACCESS FULL ALIQUOT_USER (cr = 7940 pr 7734 pw = time = 0 = 556 en)
    3406832 TABLE TEST FULL ACCESS (cr = 39236 pr 38315 pw = time = 0 = 3413192 en)
    3406832 TABLE ACCESS FULL RESULTS (cr = 107017 pr = 106053 pw = time 0 = 6848487 en)
    0 INDEX UNIQUE SCAN PK_OPERATOR_GROUP (cr = 0 pr = 0 pw = time 0 = 0 US)(object id 45769)
    0 INDEX UNIQUE SCAN PK_OPERATOR_GROUP (cr = 0 pr = 0 pw = time 0 = 0 US)(object id 45769)
    0 INDEX UNIQUE SCAN PK_OPERATOR_GROUP (cr = 0 pr = 0 pw = time 0 = 0 US)(object id 45769)
    0 INDEX UNIQUE SCAN PK_OPERATOR_GROUP (cr = 0 pr = 0 pw = time 0 = 0 US)(object id 45769)

    ********************************************************************************

    Select 'x '.
    Of
    Double


    call the query of disc elapsed to cpu count current lines
    ------- ------ -------- ---------- ---------- ---------- ---------- ----------
    Parse 1 0.00 0.00 0 0 0 0
    Run 1 0.00 0.00 0 0 0 0
    Fetch 1 0.00 0.00 0 0 0 1
    ------- ------ -------- ---------- ---------- ---------- ---------- ----------
    Total 3 0.00 0.00 0 0 0 1

    Chess in the library during parsing cache: 0
    Optimizer mode: ALL_ROWS
    The analysis of the user id: 97

    Rows Row Source operation
    ------- ---------------------------------------------------
    1 DOUBLE QUICK (cr = 0 pr = 0 pw = time 0 = 3 US)

    ********************************************************************************

    Start: id: = sys.dbms_transaction.local_transaction_id; end;


    call the query of disc elapsed to cpu count current lines
    ------- ------ -------- ---------- ---------- ---------- ---------- ----------
    Parse 1 0.00 0.00 0 0 0 0
    Run 1 0.00 0.00 0 0 0 1
    Fetch 0 0.00 0.00 0 0 0 0
    ------- ------ -------- ---------- ---------- ---------- ---------- ----------
    Total 2 0.00 0.00 0 0 0 1

    Chess in the library during parsing cache: 0
    Optimizer mode: ALL_ROWS
    The analysis of the user id: 97



    ********************************************************************************

    TOTALS FOR ALL NON RECURSIVE INSTRUCTIONS

    call the query of disc elapsed to cpu count current lines
    ------- ------ -------- ---------- ---------- ---------- ---------- ----------
    Parse 3 0.00 0.00 0 0 0 0
    Run 3 1.15 1.16 0 0 0 1
    Pick 2 8.53 16.10 227649 241266 0 501
    ------- ------ -------- ---------- ---------- ---------- ---------- ----------
    Total 8 9.68 17,27 227649 241266 0 502

    Chess in the library during parsing cache: 1
    Lack in the library during execution cache: 1


    TOTALS FOR ALL RECURSIVE INSTRUCTIONS

    call the query of disc elapsed to cpu count current lines
    ------- ------ -------- ---------- ---------- ---------- ---------- ----------
    Parse 30 0.00 0.00 0 0 0 0
    Run 30 0.00 0.00 0 0 0 0
    Get 30 0.00 0.00 0 40 0 10
    ------- ------ -------- ---------- ---------- ---------- ---------- ----------
    Total 90 0.00 0.00 0 40 0 10

    Chess in the library during parsing cache: 0

    3 the session user SQL statements.
    30 internal to SQL statements in session.
    33 SQL statements in session.
    ********************************************************************************
    Trace file: C:\oracle\product\10.2.0\admin\nautp02\udump\nautp02_ora_880.trc
    Compatibility of trace files: 10.01.00
    Sorting options: by default

    8 sessions in the trace file.
    3 SQL statements of the user in the trace file.
    30 internal SQL instructions in the trace file.
    33 SQL statements in the trace file.
    6 unique SQL statements in the trace file.
    633 lines in the trace file.
    23 seconds in the trace file.
    {code}

    ZI wrote:
    I have a statement with a decoding function in the where clause like this:

    AND decode(:cropcode,-1,'-1',sdu.u_crop_group) = decode(:cropcode,-1,'-1',:cropcode)
    

    When I have a package-1 as parameter for cropgroup the filter would result by ' AND '-1' = '-1', and the statement is executed in less than 2 seconds.»»» When I leave this where clause it takes almost 18 seconds. The result is the same so I don't understand why the explain plan command is so different and why not use index scans in the statement without decoding.

    I would interpret the results displayed differently.

    Execution which took 17 s according to the 241 266 coherent block played tkprof output gets but in order to do so he read 227 649 the disk blocks. Note that most of the table addressed by this query blocks were read through scanning of complete table that can take advantage of multiple blocks readings, for example if you unset the db_file_multiblock_read_count 10.2 (recommended) it usually try to read 1 MB with a read request, which are 128 blocks in case of standard block size 8 k. Due to several reasons not always the full size can be requested with each read request, lets say about 200 000 blocks could have been read by about 2,000 blocks multiple readings. Each read request would turn into a physical read, could you get an estimate approximate 25 MS per read times 2,000 applications-online 50 seconds (your system is running obviously better that the average assumed by ost g 10 base optimizer without collected statistics system workload, can be that some additional file caching system is involved).

    On the other hand, the execution plan that finished within 2 seconds completed 221 420 coherent block gets but did No physical reads at all. Note that most of the table blocks should be processed using one-piece random searches (ACCESS BY ROWID of the TABLE), according to the grouping of the indices factor, it could have been as many blocks that the lines have been returned to the range index scans. So you could have done with lets say more than 60,000 randomly accessed table blocks => until 60 000 monobloc required reading. So in the worst case, this may take 60 000 requests time 10ms by read-online 600 seconds, even if in reality at least some of the blocks will be stored in the buffer cache, so it should be less.

    It would be interesting to know how these two declarations with a cold buffer cache, so that both had to physical reads. I suppose the first is actually faster. Of course, if the second corresponds more to your typical situation that most of the blocks is in the buffer anyway, then it could be faster, because the blocks read by random access are more likely to stay in memory blocks read by complete sweep of the table, but in a true perspective of I/O the first is expected to be higher.

    Moreover, the change in the plan is probably caused by the fact that the additional predicate (DECODING) lowers the cardinality of the table of SDG_USER conduct so that LOOP IMBRIQUEE approach seems to be cheaper to the optimizer that the hash join/full scan table approach. Apparently the estimate is way off (by two orders of magnitude, in fact 100 instead of 1), then the plan is not really cheap, because it seems like the optimizer.

    By the way: two actual execution plans displayed in the output from tkprof are actually different from the displayed output of EXPLAIN the PLAN, so the statement has executed a little differently provided the facility to EXPLAIN the PLAN.

    Your PLAN_TABLE is old, since you are on 10g you should drop any PLAN_TABLEs that are in non - SYS diagrams, since 10 g already provides a global temporary Table as part of the default dictionary (SYS. Plan_table$ presentations via public synonym PLAN_TABLE).

    Kind regards
    Randolf

    Oracle related blog stuff:
    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/

  • Explain the explain plan

    decide to move to optimization soon. Book says join faster that the subquery in this example because the analyses involved. The "cost" to the subquery appears lower than the cost for the join. So it is confusing to me - aka How should I be interpreting this.

    Plan of subquery:

    image2.png.jpg

    join plan

    image2.png.jpg

    as you can see that the plan for the subquery has less than a cost. Could someone explain these outputs as to which application is more effective. I need to start somewhere.

    Thank you!

    The BEST way to get help when you ask questions is:

    1 ask questions on SPECIFIC things

    2. tell us EXACTLY what term, value, etc. ask abaout

    Book says join faster that the subquery in this example because the analyses involved. The "cost" to the subquery appears lower than the cost for the join. So it is confusing to me - aka How should I be interpreting this.

    OK - what BOOK are you talking about? There is not much interest to mention a book if you're not going to tell us which book it and provide a link to it and even a page number. This gives us the SCOPE of your question.

    This "cost for the subquery" are you talking about? Be specifc. It is in one of the plans that you posted? What plan? Whose cost is it? For example, you could say:

    I have a question for the foreground below. Why is the cost to the xx line lower than the cost of the second plan on line AA?

    This question refers CLEARLY to the info we're talking. The way in which you stating the question, we try to guess what plan and the lines you want to say.

    subquery plan:
    
    
    join plan
    
    
    as you can see the subquery plan has less of a cost. Could someone explain from these outputs as to which query is more efficient. I need to start from somewhere.
    

    Are you talking about line #1 in each of these plans?

    Please edit your post and tell us EXACTLY what you ask in the topic and refer to values and SPECIFIC lines. Also post a link to the book and a reference to a page number you got the information from.

    The optimizer generally chooses the REAL implementation with the lowest cost plan. It is not clear whether the plans that you have posted are ACTUAL spending plans that Oracle really determined and used or just explain plans.for what Oracle thought it might use.

    If the statistics are not up-to-date these plans do not yet reflect the reality of the data.

    And if the amount of data is a small number of blocks or other of these plans can run better than the other in reality.

    You can find this Oracle white paper "Explain the Plan explaining" useful

    http://www.Oracle.com/technetwork/database/bi-Datawarehousing/TWP-explain-the-explain-plan-052011-393674.PDF

Maybe you are looking for