Rownum and plan to see where Explain the terms > and <

Hi people...

I just wanted to share a comment... would make for a conceptual explanation on even!

SQL > select * from v version $;

BANNER

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

Database Oracle 12 c Enterprise Edition Release 12.1.0.1.0 - 64 bit Production

PL/SQL Release 12.1.0.1.0 - Production

CORE Production 12.1.0.1.0

AMT for 64-bit Windows: Version 12.1.0.1.0 - Production

NLSRTL Version 12.1.0.1.0 - Production

SQL > select count (*) in the tab_rownum where rownum < 2;

Execution plan

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

Hash value of plan: 1301825293

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

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

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

|   0 | SELECT STATEMENT |            |     1.     2 (0) | 00:00:01 |

|   1.  GLOBAL TRI |            |     1.            |          |

|*  2 |   COUNT STOPKEY |            |       |            |          |

|   3.    TABLE ACCESS FULL | TAB_ROWNUM |     1.     2 (0) | 00:00:01 |

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

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

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

2 - filter(ROWNUM<2)

Statistics

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

1 recursive calls

0 db block Gets

3 consistent gets

5 physical reads

0 redo size

542 bytes sent via SQL * Net to client

543 bytes received via SQL * Net from client

2 SQL * Net back and forth to and from the client

0 sorts (memory)

0 sorts (disk)

1 rows processed

As most of us should be aware of, First_Rows_k optimization takes place for query Rownum... !!

so for top query, the cardinality estimate is 1 and County stop happened key in the plan with filter as ROWNUM < 2.

Now let's run under SQL.

SQL > select count (*) in the tab_rownum where rownum > 2;

In any case... above SQL will be not all output lines.

As expected rownum is greater then 2... !!

allows to check the plan!

Execution plan

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

Hash value of plan: 141762995

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

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

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

|   0 | SELECT STATEMENT |            |     1.   425 (1) | 00:00:01 |

|   1.  GLOBAL TRI |            |     1.            |          |

|   2.   COUNTY |            |       |            |          |

|*  3 |    FILTER |            |       |            |          |

|   4.     TABLE ACCESS FULL | TAB_ROWNUM | 91740 |   425 (1) | 00:00:01 |

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

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

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

3 - filter(ROWNUM>2)

Statistics

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

1 recursive calls

0 db block Gets

1529 gets coherent

1526 physical reads

If we check the cardinality estimates, this is the total of the lines of the table... That's why no First_Rows_K for this SQL optimization. (All_rows)

Although we will not get all the lines... always full scan table oracle...

Also... Button Count Stop has changed and filter + Count... !!

Need to understand... Why not oracle have an output for logic > rownum conditions than zero!

Why the filter for the second execution ends not SQL executions... it scan complete set... for lines nil!

Thank you

Deepak M.

Hello

WHERE ROWNUM > 2 is a very common mistake, but it's a mistake that most people make once, in development.  They learn that it does not work, and they don't again.  I expect Oracle to make the features so that unique development queries run faster.  They are probably more concerned about what kind of things people do every day, in the Production.

Tags: Database

Similar Questions

  • WLAN file Device Manager, until I restart the machine and deletes the wifi while using it 3 times a week and no diagnosis to see where is the problem

    I think someone put the wrong card in this or changed when I bought it was 3 weeks ago. dw1510 card wlan and broadcom driver date tried 2008 update and does not say supported.makes no sense not supported. Why wifi falls and have to restart are beyond me. I ask those with same past answer questions and if your card is different from dw1510 tell me your card. LAN hardware card. AND WHEN I TRY TO INSTALL THE DRIVER FROM DELLS FOR HIM, IT SAYS HARDWARE NOT SUPPORTED. GO FIGURE?

    Hello

    Welcome to the Microsoft community.

    I understand that you have a problem with WLAN.

    To help you better I would like to know the details below.

    1. What is the brand and model of the computer and the Wi - Fi router?
    2. You get no matter what code/error message when disconnecting a Wi - Fi connection? If Yes, then give the complete error message/code.
    3. You did changes to the computer before the show?

    I ask you to perform the following steps of the Microsoft Help article and check if it helps.

    Wireless and wired network problems

    http://Windows.Microsoft.com/en-us/Windows/network-connection-problem-help#network-problems=Windows-7&V1H=win81tab1&V2H=win7tab1&V3H=winvistatab1&v4h=winxptab1

    Meet us with results to help you best.

  • Planer VMware capacity - where is the documentation

    Because we want to have a complete picture of our physical environment (before go us completely virtualized) I tried to use the Planer capability integrated into Virtual Center.

    The tool has a lot of potential, but without documentation, there are also a lot of trial and error, so that I didn't have the time.

    I have seen also some web reporting tool, that I could not access...

    Anyone know where to find the docs?

    Concerning

    SPEX

    We had CDW come and help us with the Capacity Planner thing.  Its a free service, but they have obviously will want to sell you something so that on-site.

    Here's a collection of URLS, I for this product:

    VMware Capacity Planner

    http://www.VMware.com/files/PDF/datasheet_capacity_planner.PDF

    Data collection Guide

    https://optimize.VMware.com/support/CP-DataCollectionGD.PDF

    The dashboard user guide

    https://optimize.VMware.com/support/CP-Userguide.PDF

    Capacity Planner technical FAQ

    http://VMETC.com/wp-content/uploads/CP_Tech_FAQ.PDF

    Capacity Planner security FAQ

    http://VMETC.com/wp-content/uploads/CP_Security_FAQ.PDF

    FAQ sales Capacity Planner

    http://VMETC.com/wp-content/uploads/CP_Sales_FAQ.PDF

    Not sure if this will help, but thought I'd throw them out there.

    Good luck!

  • Can I rent a movie from iTunes and then see it on the plane?

    Can I rent a movie from iTunes and then see it on the plane?

    In principle Yes. See about renting movies from the iTunes Store - Apple Support. Pay attention to this section:

    To watch your movie when you are disconnected, as on a flight from the airline where there is a Wi - Fi connection:

    • Download the whole movie before going offline.
    • Press play to start watching. The 24 hour timer starts even if you are offline.

    You may want to download rented movies before the day of your trip to make sure you have the time to download all the content.

    TT2

  • How to understand the implementation of the plan in oracle I mean if I see two implementation plans for a single sql_id plans 2 How to determine the best execution plan? Links and answers are much appreciated. Thank you

    How to understand the implementation of the plan in oracle I mean if I see two implementation plans for a single sql_id plans 2 How to determine the best execution plan? Links and answers are much appreciated. Thank you

    How to understand the implementation of the plan in oracle I mean if I see two implementation plans for a single sql_id plans 2 How to determine the best execution plan? Links and answers are much appreciated. Thank you

    After two execution plans that have the same sql_id, so we can see what you're talking about.

    See "Oracle Explain Explain Plan optimizer" by Maria Colgan of the Oracle optimizer group

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

    Examine the various aspects of a selectivity to parallel execution plan

    performance and understand what information you should be brilliant

    the plan can be overwhelming even for the most experienced DBA. This document

    offers a detailed explanation on each of the aspects of the execution plan and a

    Overview of what caused the CBO to make the decision, he did.

  • explain the plan and so on

    Hello world


    could someone please provide me with details of explained the plan and I would appreciate some related details explain plan, trace and tkprof

    Thank you
    Shareef

    Hello

    PLAN of EXPLAINING is an Oracle utility that analyzes a statement and shows the expected execution plan. It may be different from the implementation plan real for a number of reasons.

    Extended SQL trace (10046 event) is a way to gather advanced diagnostic information. There are different levels, at levels 8 and 12 provide the greatest level of detail (you will be able to see the events of waiting and the bind variable values).

    TKProf is a utility that processes the raw trace files and makes shaped the output in a more readable way. However, some experts prefer to work with trace files "gross" - they are not so difficult to read, especially if you get some practice.

    There are other events of tracing: 10053 allows you to see what is happening inside the Oracle optimizer, 10104 allows to see the stats of hash etc join.

    Best regards
    Nikolai

  • I have formatted my system and windows reloaded. Then, I clicked on it somewhere (do not remember on which/wher) now the systym not to see any how removable storage or don't want even to open a CD I put in...

    I have formatted my system and windows reloaded. Then, I clicked on it somewhere (do not remember on which/wher) now the systym not to see any how removable storage or don't want even to open a CD I put in...

    As you reinstalled just Vistas, you would have a very limited number of Restore Points!

    Try the system restore.

    If this does not work, and you don't know what you were doing, reinstall it again.

    http://www.howtogeek.com/HOWTO/Windows-Vista/using-Windows-Vista-system-restore/

    Do Safe Mode system restore, if it is impossible to do in Normal Mode.

    Try typing F8 at startup and in the list of Boot selections, select Mode safe using ARROW top to go there > and then press ENTER.

    Try a restore of the system once, to choose a Restore Point prior to your problem...

    Click Start > programs > Accessories > system tools > system restore > choose another time > next > etc.

    See you soon.

    Mick Murphy - Microsoft partner

  • I use Foglight 5.6.5 and I was wondring where, in the dashboard - we can see the foglight agents associated ip addresses. There are many times we need the ip address of a host, I want to add a custom dashboard if necessary to include this

    I use Foglight 5.6.5 and I was wondring where, in the dashboard - we can see the foglight agents associated ip addresses. There are many times we need the ip address of a host, I want to add a custom dashboard if necessary to include this

    George, was the question that you asked:

    "How can I find the IP addresses of remote hosts being monitored?

    or

    "How can I find the IP address of the FGLAM server that is monitoring?

  • I took my mac repair, they ended up replacing my computer, I got the package of cloud of Photoshop and Lightroom but logging into my account I do not see where to download it again? I still pay every month I just need the programs...

    I took my mac repair, they ended up replacing my computer, I got the package of cloud of Photoshop and Lightroom but logging into my account I do not see where to download it again? I still pay every month I just need the programs...

    Click on the link below and download Creative Cloud Installer file and use them to install the creative Cloud Desktop application.

    https://ccmdls.Adobe.com/AdobeProducts/KCCC/1/OSX10/CreativeCloudInstaller.dmg

    Once you have installed Adobe Creative Cloud app, you can reinstall all applications CC:

    Reference:

    https://helpx.Adobe.com/creative-cloud/help/download-install-app.html

  • difference between the execution plan and explain the plan?

    What is the difference between the execution plan & explain the plan?

    an execution plan is the actual steps that oracle will pass by when it executes a query.

    explain plan is a tool that is used to generate the steps of an execution plan for a query.

  • Question about cardinality (lines) to explain the plan

    I have two tables (names have been changed to protect the innocent):


    TABLE 1:


    The Null columns?    Type

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

    Table1_Primary_Key NOT NULL NUMBER

    more than 10 columns


    TABLE2:


    The Null columns?    Type

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

    Table2_Primary_Key NOT NULL NUMBER

    more than 8 columns


    Lines of table1 has 1097172


    Rows of table2 has 160960


    I am analysis request and get explain below:


    SELECT t1. Table1_Primary_Key

    --

    FROM TABLE1 t1,

    From TABLE2 T2

    --

    WHERE t1. Table1_Primary_Key = t1. Table1_Primary_Key

    AND t2. Table2_Primary_Key = 3432798

    /


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

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

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

    |   0 | SELECT STATEMENT |                 |     1.    21.     5 (0) | 00:00:01 |

    |   1.  NESTED LOOPS |                 |     1.    21.     5 (0) | 00:00:01 |

    |   2.   TABLE ACCESS BY INDEX ROWID | TABLE2.     1.    12.     3 (0) | 00:00:01 |

    |*  3 |    INDEX UNIQUE SCAN | TABLE2_PK |     1.       |     2 (0) | 00:00:01 |

    |   4.   TABLE ACCESS BY INDEX ROWID | TABLE1.  1096K |  9634K |     2 (0) | 00:00:01 |

    |*  5 |    INDEX UNIQUE SCAN | TABLE1_PK |     1.       |     1 (0) | 00:00:01 |

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


    As you can see it table2 is exactly 1 row and join table1 on a correspondence of single line.


    My question is this:


    Why the plan of the explain command seems (at least for me) to indicate that it looked like all the rows in TABLE1?


    Thank you


    Thomas

    the optimizer's decisions are based on the object (and maybe system) statistics: so it's a good idea to provide as much information as possible in these statistics. Basically, there is nothing wrong with statistics automatic collection job - so I would count on that if I don't have very good reason to use anything else. Of course, there are some situations in which it's a good idea to add a few adjustions for automatic collection: sometimes, there is too much created histograms, sometimes there is too little (basically you have histograms when the distribution of the data is not yet). And if there are columns with correlated values who serve together in boundary conditions then create extensive statistics may be a good idea. To make these adjustions, you can use the routines of pref dbms_stats. And sometimes, it may even be a good idea is not to collect statistics for an object and use the sample dynamic (dynamic statistics) for more detailed information on the cardinality of distribution and join.

    In the book of my opinion Jonathan Lewis cost base Oracle Fundamentals still contains the best explanation of the use of optimizer statistics - and Christian Antognini Oracle performance troubleshooting also provides a lot of valuable information about statistics and their gathering. Of course the documentation also explains the basics in detail: Managing optimizer statistics - 11 g Release 2 (11.2). And if you want to get a shorter summary, then you can always take a look at the Web of Tim Hall site: https://oracle-base.com/articles/misc/cost-based-optimizer-and-database-statistics.

  • explain the research plan

    Hi all

    I have a SQL query that joined with temporary tables total and normal tables.
    I created indexes on global temporary tables with the column that is used
    in where condition.

    But when I check the explain command plan I see this full table access with cost like 2.
    This full table access is child of nested loops.

    Is that with plan or should I adjust more.
    Please advice

    Thanks and rgds
    Saaz

    Are the line estimates accurate?

    Given that all say 1 and dynamic sampling has been used, it is likely that you have no stats gathered for these objects?

  • Using Planning with FDQM, where the essbase adapters?

    Hello

    I have EMP system version 11 is installed and worked with planning. I don't know a lot about the quality of financial data management, but want to explore its capabilities and use it with the planning. I created a new application of FDM following John Goodwin blog [http://john-goodwin.blogspot.com/2008/07/planning-v11-drill-back.html].

    In the Oracle documentation, he speaks of adapters, and the blog explains the essbase adapter must be imported, which "consists of an executable file (upsES9XG4B.exe) and an xml file (ES9x-G4 - B.xml). I am not able to locate these files in the directory of Hyperion. Does anyone know where they might be? Could I have failed to bring with my installation, or could they be called something else? No indication using FDM with the planning would be appreciated, including pointing to specific areas in the documentation, I have forgotten. Thank you.

    Hello

    It will cause no conflict so you can download them again without problem, you can have them already, but they will not be installed because you have to do it manually.

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • Icon for Windows 8.1 that allows me to see all of the programs and the previous documents, computer etc.

    On my Windows 7, there is an icon in the lower left corner which is round and has 4 flags inside.  Red, green, blue and yellow.  When I click on this icon, I see my computer, all programs, music, Control Panel documents and I can then click on one of those to see exactly what I want.  Is this icon on 8.1 and if so how can I find?  If this isn't the case, which has taken its place?

    Hello Clint01,

    Welcome to the HP Forums, I hope you enjoy your experience! To help you get the most out of the Forums of HP, I would like to draw your attention to the Guide of the Forums HP first time here? Learn how to publish and more.

    I understand that you have moved to Windows 8.1 and are curious to know where is the Start button. There has been major changes to the Windows operating system, and the location and the function of the Start button has changed. I provided you a document of teak of Yahoo I found makes a very good job of explaining what has happened and what has taken its place in the way of the Start button. The article is How to recover the real Start Menu in Windows 8 or 8.1 , and I think it will answer your question to your satisfaction.

    I hope that I have answered your question to your satisfaction. Thanks for posting this question on the Forums of HP. Have a great day!

  • 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

  • I want to use a function as a line number

    This should be simple.  Just need the syntax to do this correctly. The row number of the cell, I want to refer is a function. Instead of something simple like B3, the idea is B (row () * 4) but which generates a syntax error.  B is not a function. So

  • How to clean the screen of the iMac 27 "?

    What is the best way to clean the screen of the iMac 27 "? I'm afraid to use a liquid cleaner for these surfaces, but it's the best. In my case, I only clean with a soft, dry cloth. Any suggestion?

  • Tecra 550cdt enabling the DMA mode

    Hello, I have a 550Cdt Tecra using windows 98se, I would activate the DMA mode for my hard disk drive, if enable DMA, after windows restarts, it stops showing the windows startup logo. I have to stop the laptop with the power button. In this case, I

  • Windows 7 64 bit drivers for HP ENVY 17-3000 card reader

    Hello I reinstalled Windows 7 from the disc and can not get the card reader to work properly. I tried the drivers on the site and it installs but still does not work. Below, I've given my hardware ID in the hope that this will help you to help me wit

  • Service SecurityCenter

    Can someone help me to reinstall my Service Security Center. Ann_843