Difference between INLINE view and WITH clause

Can anyone plz explain me about the performance difference between the below queries?
Query using INLINE view:
SELECT e.ename AS employee_name,
dc.dept_count AS emp_dept_count
FROM emp e,
(SELECT deptno, COUNT(*) AS dept_count
FROM emp
GROUP BY deptno) dc
WHERE e.deptno = dc.deptno;
Query using WITH clause:
WITH dept_count AS (
SELECT deptno, COUNT(*) AS dept_count
FROM emp
GROUP BY deptno)
SELECT e.ename AS employee_name,
dc.dept_count AS emp_dept_count
FROM emp e,
dept_count dc
WHERE e.deptno = dc.deptno;

Here's another one:
http://www.oracle-base.com/articles/misc/WithClause.php
And, here on this forum you will see that the WITH-clause is heavily used by all of us in order to generate some sample data (when OP's don't care to post CREATE TABLE + INSERT INTO statements).
The WITH clause enables you as well to 'pretend' you have a table and demonstrate a solution very quickly, without doing actual DDL .
As for the performance difference:
We would need to know your database version and many other things.
See:
HOW TO: Post a SQL statement tuning request - template posting
for step by step instructions you can (and should) explore yourself.

Similar Messages

  • Difference between inline view and WITH

    All,
    What is the difference between an inline view and a query using 'with' keyword...? (scenario / example will be more helpful)

    Thank-you ajay. below section was really helpful, in the above link.
    big_table@ORA920> set echo on
    big_table@ORA920> set autotrace on statistics
    big_table@ORA920>
    big_table@ORA920> with owners
    2 as
    3 ( select distinct owner username from all_objects )
    4 select count(*)
    5 from all_objects, owners
    6 where all_objects.owner = owners.username
    7 union all
    8 select count(*)
    9 from dba_objects, owners
    10 where dba_objects.owner = owners.username
    11 /
    COUNT(*)
    30537
    30977
    2 rows selected.
    Statistics
    4 recursive calls
    7 db block gets
    302441 consistent gets
    1 physical reads
    520 redo size
    418 bytes sent via SQL*Net to client
    499 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    3 sorts (memory)
    0 sorts (disk)
    2 rows processed
    big_table@ORA920>
    big_table@ORA920> select count(*)
    2 from all_objects, (select distinct owner username from all_objects ) owners
    3 where all_objects.owner = owners.username
    4 union all
    5 select count(*)
    6 from dba_objects, (select distinct owner username from all_objects ) owners
    7 where dba_objects.owner = owners.username
    8 /
    COUNT(*)
    30537
    30977
    2 rows selected.
    Statistics
    28 recursive calls
    0 db block gets
    442058 consistent gets
    0 physical reads
    0 redo size
    418 bytes sent via SQL*Net to client
    499 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    4 sorts (memory)
    0 sorts (disk)
    2 rows processed
    big_table@ORA920> set autotrace off
    Edited by: sikander on Sep 9, 2010 12:39 AM
    Edited by: sikander on Sep 9, 2010 12:40 AM

  • Hi,  difference between database view and elementary search help

    hi
    pl.  can any one tell me the difference between
    database view and elementary search help, 
    and  help view and elementary search help,
    and database view and help view.
    in the output i do not see any difference.
    thanx.
    rocky robo

    HI
    An entire table can be included in a database view. In this case all the fields of the included table will become fields of the view (whereby you can explicitly exclude certain fields). If new fields are included in the table or existing fields are deleted, the view is automatically adjusted to this change.
    Database view:
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/36/74c0358373003ee10000009b38f839/frameset.htm">http://help.sap.com/saphelp_nw04/helpdata/en/36/74c0358373003ee10000009b38f839/frameset.htm</a>
    Elementary search help:
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee38446011d189700000e8322d00/frameset.htm">http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee38446011d189700000e8322d00/frameset.htm</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/8b/415d363640933fe10000009b38f839/frameset.htm">http://help.sap.com/saphelp_nw04/helpdata/en/8b/415d363640933fe10000009b38f839/frameset.htm</a>
    Help view:
    Help views are used if a view with an outer join is needed as selection method in a  search help.
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/42/81c1351181b73fe10000009b38f839/frameset.htm">http://help.sap.com/saphelp_nw04/helpdata/en/42/81c1351181b73fe10000009b38f839/frameset.htm</a>
    Regards,
    Gunasree

  • Difference between Database view and Table

    Hi there,
    Can anyone tell me the difference between Database view and Table.
    Will the Database view query be more faster than a database table?

    Tables and database views can be defined in the ABAP Dictionary.
    These objects are created in the underlying database with this definition. Changes in the definition of a table or database view are also automatically made in the database.
    Data from several tables can be combined in a meaningful way using a view (join).
    You can also hide information that is of no interest to you (projection) or only display
    those data records that satisfy certain conditions (selection).
    Database views implement an inner join. You only get those records which have an
    entry in all the tables included in the view.
    in views db modifications are not possible
    views only contain data at run time
    when they consult the database
    in case of views the join definitions are already sstored in the database itself
    whereas join as open sql is a query to oracle  database as similar select statements
    Views are optimized by SAP and stored in the repository while Joins
    are in reports that needs to be compiled at every execution
    Reward if helps
    Regards,
    Senthil
    Message was edited by: senthil kumar

  • Difference between interface view and interface controller

    Hi,
    What is the difference between interface controller and interface view?
    When we will use interface controller and when we will use interface view?
    How do we create an interface view?
    How do we attach this interface view to a view in another component
    Regards
    MQ

    Hi
    Interface View Controllers
    A) Implement event handlers which are called when ..
           -starting (start-up plugs) Web Dypro applications
           -a component is reached via navigation (inbound plugs)
    B) Allow fireing outbound plugs (navigation)
    C) Allow firing exit plug
    D) Have no own context, public methods or events
    Interface Controller of a Component
    The interface controller of a Web Dynpro component contains all context nodes, events and methods of the component controller to which you assigned the Interface addition in the Controller Editor. These parts can be displayed in the interface controller view, although you cannot edit them here.
    Interface Controller of a Component Interface
    A Web Dynpro component interface can be created independently and defined so that it can be implemented later in any components (see working with Web Dynpro Component Interfaces in the Programming Manual of this documentation). That is why in this case you can define the context nodes, methods and events you require in the interface controller view. The relevant implementation then takes place in the component controller of the implementing component.
    Check this links and work on it.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/28113de9-0601-0010-71a3-c87806865f26?rid=/library/uuid/49f2ea90-0201-0010-ce8e-de18b94aee2d#13 [original link is broken]
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/28113de9-0601-0010-71a3-c87806865f26?rid=/library/uuid/49f2ea90-0201-0010-ce8e-de18b94aee2d#12 [original link is broken]
    Interface view and interface controller
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f727d100-0801-0010-4cbd-b0ad5c161945
    Difference between custom controller and interface component
    Thanks and Regards,
    Tulasi Palnati

  • Wrong position of objects / difference between editor view and browser view.

    Dear Adobe
    System info: Mac OS X 10.9, Muse 7.1 Build 329, Chrome, Safari and Firefox in the newest versions.
    I use Muse since version 5 and this effect does exist 'til today (v7.1) without any changes.
    Many times i have differences in the position of placed objects. But this missbehaviour is not realy logical. For example take a look to this illustration:
    Left: Muse Editor, right: Browser (in this case its chrome, but the effect is identical in safari and firefox too)
    Left you see one pixel space between the blue bar and the shadow (image-object). In the browser is the space bigger (2px). When i move the shadow-object in muse one pixel higher, then look this so:
    The shadow is now within the bluebar. The position has changed in muse for 1 pixel, in browser around 7 pixels... i don't see, why.
    Another example:
    Left Muse Editor, right Browser... do you see the dramatic difference between?
    I hope, this problem can be solved with a future version...
    Best regards
    Michael

    This variation is due to the difference in the layout of text between Design view and Preview, which is representative of the variations that exist between browsers, OSes, devices and individual versions of each of those.
    It's impossible to reverse engineer the structure of the objects from the screenshots, but how the objects or individual sized and positioned relative to one another is key to understanding (and explaining) what you're encountering.
    If you provide the URL for this page I'll attempt take a look at it and provide some guidance for how to achieve the effect you're looking for within the constraints inherent in working with live text on the web.
    (In case you're not already aware, you can Publish to a free trial site on Adobe Business Catalyst at any time using the Publish button. Using trial sites on BC is very convenient, even if you don't plan to host the finished site on BC.)

  • Differences Between Entry View and GL View - Doc. Splitting

    Hello Experts,
    I need some help about an issue occuring in our Client right now, differences in Entry view and GL View. Any help will be appreciated.
    - Debit or Credit Balance posting of an account does not match with the balance posted in GL View, generally the GL view posts an amount above of the Entry view, and then it cause the Debit/Credit balance does not match with the movement in Entry View. Example Below from Quality System:
    Debit Balance in January 2013: 319.794.641,38
    Movement from FAGLL03 - OK.
    Movement from FBL3N - Entry View Difference: 319.794.619,86 - 319.794,641,38 = 21,52 Debit
    Checking NEW-GL Movement, we found the posting difference:
    The Document Entry View: 5.465,22 Credit From Bank Account
    The GL View - SAP Credited 5.486,74 Bank Account PC 1411 and Cr Bank Account PC 1444.
    Total:  -5.486,74 + 21,52 = 5.465,22 OK on Balance, but not OK from movement considering the Entry view.
    - Questions:
    - I understood the calculations, it was calculated as mentioned in note 1072850_Field overflow or very large amounts due to doc splitting
    - Is this supposed to happen by SAP Doc.Splitting perspective?
    - I am facing this issue because we need to send to the government account balances and their movements, and according to laws we need to pay additional amount for addtional lines generated, so it was better to send the information based in Entry View, not in GL View.
    - FS10N Show warning message "New general Ledger Implemented, use FAGLB03", and when i execute the transaction the balance showed was the balance from FAGLB03.
    - SAP 605 APPL.
    Regards,
    Leandro.

    Hi ,
    Can you Please look at OSS note
    1655571 - Multiple values and multiple/additional line items appearing in the NewGL View when compared to Entry View
    Many Thanks

  • Difference between materailized view and a table

    hey hiii
    i want to know what is a difference between a materialized view and a table i.e suppose i create a table A and another table B on table A i have created a trigger which will upload all the changes made in A ie insert,update or delete so whether this will perform all the action that a materialized view can perform on A or is there any difference between them
    thks

    I'll add to Nicolas' answer that the MV maintenance does have access to mechsnisms other than row-by-row replication of the trigger-based type. Direct path inserts to the base table are very efficiently propagated to the MV, as are partition-based DDL operations. Also MV's come with optional query rewrite built in (you need 10g+ to query rewrite to a non-MV data set), and scheduled refresh so you can defer maintenance of the data set until later.
    MV maintenance can be less efficient though -- you may know something about the data and the way that it changes that allows you to write more efficient meintenance than the MV code.

  • What is the difference between Saved views and queries

    Hi all,
    Just i want to know the difference between 2 options in the Bex Analyzer.  Those options are "Queries" and " Saved Views". Please check it out and let me know the difference

    To add to the previous posts, saved views can also be useful when developing web templates. You can create and save one query and then save a number of views from this query, with different layouts, filters etc. web templated can then be developed using the saved views. BW 2004s introduces a whole load of standard functions to switch dataproviders in web templates. Thes can be used to switch between a number of views in a template. I have used this to present selections of key figures, switch navigation states etc.
    Regards
    Peter

  • What the difference between Canvas,View and Form

    hi
    What the difference between canvas and view and form
    why asking becoz i find form builder reference
    built in like FIND_CANVAS
    FIND_VIEW
    FIND_FORM
    What the difference between these 3
    thanks in advance
    prasanth a.s.

    Asuri - with all these questions you are posting it looks like you are sitting and exam or an interview. The best advice I can give you is the skill of being able to research answers yourself.
    I would encourage you to get familiar with the online help and the various documents on OTN - this will give you knowledge; not just answers.
    Regards
    Grant Ronald
    Forms Product Management

  • Differences between controller/view & pages with flow logic

    Hi experts!!
    I am trying to create a BSP using the SBOOKSHOP tutorial.
    What i have not understood so far is the differnce between creating a bsp with pages with flow logic,
    and using the controller/ view method.
    When should we use the first and when the other approach??
    Any link to documentation would be appreciated!
    Thank you!!

    Hi Grigoria Koutsogianni,
    I hope the older thread on the same topic could help you understand the difference!
    1. Re: Understanding easy BSP development (MVC vs. Flow Logic and more...)
    2. Re: diffrence between MVC and Classical Bsp application
    -Maheswaran

  • Why is there difference between Adobe Viewer and Dev ipa?

    Hello all
    I think I am just going insane
    I have check my folio in the adobe app, which is fine
    But when i test it in the dev ipa, I have some problem like
    I am blocked in some page: impossible to scroll down or left/right to another page or stack (I have the prob in some page wich have video, or only static image with text)
    Some mpg animation doesnt play well, for ie they play first when you arrive in the page, but when you scrolldown to the page below and go back to the previous, le video has return to its first image
    It is SO annoying to have such differences between the 2 apps
    How can we fix that?

    Yes my dev app is also v18 enable
    So when I take out the PDF option when importing my folio, I dont have anymore the prob of swiping to the other pages
    But I still have the prob with my video (that goes back to the first image as soon as went to the page below - same stack- and play a bit with scrollable page button etc) then when i go up to the first page of my stack it went back and stop to the first image of the video.... same thing if it is a small video like a graph on the second page.... but this doesnt come from the Pinch and zoom option because I just re import my folio as AUTOMATIQUE and I still have this prob a video.... gonna try something else

  • [8i] Performance difference between a view and an in-line view?

    I have a query with a few 'UNION ALL' statements... each chunk of the query that is joined by the 'UNION ALL' references the same in-line view, but in each chunk it is joined to different tables. If I actually create the view and reference it in each chunk, will it still run the query behind the view for each chunk, or will it only do it once? I just want to know if it will improve the performance of my query. And, I'm not talking about creating a materialized view, just a regular one.

    Because of the complexity of my query, I tried out a simple (really simple) example instead...
    First, I created my simple view
    Then, I ran a query with a UNION ALL in it against that view
    Next, I ran the same UNION ALL query, but using in-line views instead of the one I created, and these are the results I got:
    (against the view I created)
    890 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=RULE
       1    0   UNION-ALL
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'PART'
       3    2       INDEX (RANGE SCAN) OF 'PART_PK' (UNIQUE)
       4    1     TABLE ACCESS (BY INDEX ROWID) OF 'PART'
       5    4       INDEX (RANGE SCAN) OF 'PART_PK' (UNIQUE)
    Statistics
             14  recursive calls
              0  db block gets
           1080  consistent gets
            583  physical reads
              0  redo size
          54543  bytes sent via SQL*Net to client
           4559  bytes received via SQL*Net from client
             61  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
            890  rows processed
    timing for: query_timer
    Elapsed: 00:00:01.67(with in-line views)
    890 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=RULE
       1    0   UNION-ALL
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'PART'
       3    2       INDEX (RANGE SCAN) OF 'PART_PK' (UNIQUE)
       4    1     TABLE ACCESS (BY INDEX ROWID) OF 'PART'
       5    4       INDEX (RANGE SCAN) OF 'PART_PK' (UNIQUE)
    Statistics
              0  recursive calls
              0  db block gets
           1076  consistent gets
            582  physical reads
              0  redo size
          54543  bytes sent via SQL*Net to client
           4559  bytes received via SQL*Net from client
             61  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
            890  rows processed
    timing for: query_timer
    Elapsed: 00:00:00.70Here, it appears that the explain plans are the same, though the statistics and time show better performance with using in-line views...
    Next, I tried the same 2 queries, but using the CHOOSE hint, since the explain plans above show that it defaults to using the RBO...
    Here are those results:
    (hint + use view)
    890 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=HINT: CHOOSE (Cost=1840 Card=1071
               Bytes=57834)
       1    0   UNION-ALL
       2    1     TABLE ACCESS (FULL) OF 'PART' (Cost=920 Card=642 Bytes=3
              4668)
       3    1     TABLE ACCESS (FULL) OF 'PART' (Cost=920 Card=429 Bytes=2
              3166)
    Statistics
             14  recursive calls
              8  db block gets
          12371  consistent gets
          10850  physical reads
              0  redo size
          60726  bytes sent via SQL*Net to client
           4441  bytes received via SQL*Net from client
             61  SQL*Net roundtrips to/from client
              2  sorts (memory)
              0  sorts (disk)
            890  rows processed
    timing for: query_timer
    Elapsed: 00:00:02.90(hint + in-line view)
    890 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=HINT: CHOOSE (Cost=1840 Card=1071
               Bytes=57834)
       1    0   UNION-ALL
       2    1     TABLE ACCESS (FULL) OF 'PART' (Cost=920 Card=642 Bytes=3
              4668)
       3    1     TABLE ACCESS (FULL) OF 'PART' (Cost=920 Card=429 Bytes=2
              3166)
    Statistics
              0  recursive calls
              8  db block gets
          12367  consistent gets
          10850  physical reads
              0  redo size
          60726  bytes sent via SQL*Net to client
           4441  bytes received via SQL*Net from client
             61  SQL*Net roundtrips to/from client
              2  sorts (memory)
              0  sorts (disk)
            890  rows processed
    timing for: query_timer
    Elapsed: 00:00:02.99Obviously, for this simple example, using the CHOOSE hint caused worse performance than letting it default to the RBO (though the explain plans still look the same to me), but what I find interesting is that when I used the hint, the version of the query using the in-line view became at least equivalent to the one using the view, if not worse.
    But, based on these results, I don't know that I can extrapolate to my complex query... or can I? I'm thinking I'm going to have to actually go through and make my views for the complex query and test it out....

  • What is the difference between materialised view and normal view?

    please expalin the difference in detail with an example.
    thanks.

    Hi User,
    Welcome to Forum !!!!
    Materialized view is nothing but a database Object similar to Tables,Indexes,Procedures etc.
    It contains the results of a query.
    The materialized view is refreshed when the query is executed. And are refreshed on demand
    Unlike Views, it contain data.
    It does not contain real-time data.
    Materialized view are called Snapshot(In Older Versions of Oracle).
    Thanks,
    Shankar

  • I'd like to know the difference between Flat view and Threaded view in the forum.

    anyonw know?
    discussion view style and comment view style
    any difference? i have not noticed any

    threaded view will not display posts which are replys to other posts in the main view
    only when you click on the original post will you see them

Maybe you are looking for

  • Comp viewer becomes flat blue at certain zoom levels

    This is a problem I've had with several different versions of After Effects, and on more than one computer and I haven't been able to find any information about it. Sometimes, especially after RAM previewing, my comp viewer will turn blue and I can't

  • User exit EXIT_SAPLMV01_002

    Hi All, I have been given this user exit where i have insert a logic which will over write standard fields of MARA table with custom fields. My question is how to test my logic whether it is working fine or not? I am using this user exit for outboud

  • Distorted video in iMovie '09 Version 8.0.6 (821)

    We're doing a video project at school and have an issue with videos that we've taken with the iPad and iPhone. The iPad was held vertically and when the clips were imported into iMovie '09, the clips are visually distorted; ie the students on camera

  • User Exit/BADI for transaction FTR_CREATE/FTR_EDIT

    Hi, Have anybody worked on any userexit or BADI on tcode FTR_CREATE or FTR_EDIT? I've been searching for a userexit/badi when I save the contract. Till now I found none. I need to validate limit amount of contract when save event is triggered. Any in

  • Disk Restore Error with DU (HELP!!)

    OK I created an image flawlessly or so I thought. When I went to restore and began the process, after I entered my Admin Password it looks like it will start and then I received the Error Message 'Cannot connect to helper tool' and the restore is abo