Confused by the change in logical IO when using a UNION

Hi,
we were discussing tuning strategies (using SQL*Plus and autotrace) and stumbled over a strange behaviour.
When I do a straight select I get the following output:
SQL> select * from orders where id > 600000;
100000 rows selected.
Execution Plan
Plan hash value: 1275100350
| Id  | Operation         | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT  |        | 99585 |  2236K|   436  (14)| 00:00:07 |
|*  1 |  TABLE ACCESS FULL| ORDERS | 99585 |  2236K|   436  (14)| 00:00:07 |
Predicate Information (identified by operation id):
   1 - filter("ID">600000)
Statistics
          0  recursive calls
          0  db block gets
       9473  consistent gets
          0  physical reads
          0  redo size
    3353061  bytes sent via SQL*Net to client
      73711  bytes received via SQL*Net from client
       6668  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
     100000  rows processed
SQL>which is more or less what I expected. Now the strange thing comes when I change the statement to
select * from orders where id > 600000 and id < 630000
union
select * from orders where id >= 630000;which selects the same set of data. Of course the execution plan changes for this query, but what really puzzles me is the huge different for logical IO (consistent gets)
SQL> select * from orders where id > 600000 and id < 630000 union select * from orders where id >= 630000;
100000 rows selected.
Execution Plan
Plan hash value: 2377290594
| Id  | Operation                     | Name      | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT              |           | 99587 |  2236K|       |  1242  (71)| 00:00:19 |
|   1 |  SORT UNIQUE                  |           | 99587 |  2236K|  7088K|  1242  (71)| 00:00:19 |
|   2 |   UNION-ALL                   |           |       |       |       |            |          |
|   3 |    TABLE ACCESS BY INDEX ROWID| ORDERS    | 29914 |   671K|       |   184   (3)| 00:00:03 |
|*  4 |     INDEX RANGE SCAN          | PK_ORDERS | 29914 |       |       |    61   (4)| 00:00:01 |
|   5 |    TABLE ACCESS BY INDEX ROWID| ORDERS    | 69673 |  1564K|       |   424   (3)| 00:00:07 |
|*  6 |     INDEX RANGE SCAN          | PK_ORDERS | 69673 |       |       |   139   (4)| 00:00:03 |
Predicate Information (identified by operation id):
   4 - access("ID">600000 AND "ID"<630000)
   6 - access("ID">=630000)
Statistics
          0  recursive calls
          0  db block gets
        594  consistent gets
          0  physical reads
          0  redo size
    3353061  bytes sent via SQL*Net to client
      73711  bytes received via SQL*Net from client
       6668  SQL*Net roundtrips to/from client
          1  sorts (memory)
          0  sorts (disk)
     100000  rows processed
SQL>Even though the same number of rows is selected, and the same number of bytes are sent to the client, why is the number of logical IOs so much lower?
When I change the UNION to a UNION ALL the consistent gets go way up (13893) which I don't understand as well (the execution plan is basically the same, just missing the SORT UNIQUE node)
Can anyone shed some light on this? Especially why the UNION needs substantially less IO
I would have expected it to use more IO due to the duplicate index range scan. More like the figures I get when using UNION ALL
This is on a developer machine. Windows XP, Oracle 10.2.0.1.0
Thanks in advance
Thomas

Thanks for the answer.
Yes, the statistics are up-to-date.
Yes I have noticed the full table scan, but when I change the condition for the first select in order to reduce the number of rows so that an index range scan makes sense, the figures are more or less the same:
SQL> select * from orders where id > 630000;
70000 rows selected.
Execution Plan
Plan hash value: 1270478249
| Id  | Operation                   | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT            |           | 69672 |  1564K|   424   (3)| 00:00:07 |
|   1 |  TABLE ACCESS BY INDEX ROWID| ORDERS    | 69672 |  1564K|   424   (3)| 00:00:07 |
|*  2 |   INDEX RANGE SCAN          | PK_ORDERS | 69672 |       |   139   (4)| 00:00:03 |
Predicate Information (identified by operation id):
   2 - access("ID">630000)
Statistics
          0  recursive calls
          0  db block gets
       9724  consistent gets
          0  physical reads
          0  redo size
    2627301  bytes sent via SQL*Net to client
      51711  bytes received via SQL*Net from client
       4668  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
      70000  rows processedWhen I change the condition for the union to only retrieve 70000 rows as well, I get figures comparable to my very first example:
SQL> select * from orders where id > 630000 and id < 650000 union select * from orders where id >= 650000;
70000 rows selected.
Execution Plan
Plan hash value: 2377290594
| Id  | Operation                     | Name      | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT              |           | 69673 |  1564K|       |   871  (73)| 00:00:13 |
|   1 |  SORT UNIQUE                  |           | 69673 |  1564K|  4977K|   871  (73)| 00:00:13 |
|   2 |   UNION-ALL                   |           |       |       |       |            |          |
|   3 |    TABLE ACCESS BY INDEX ROWID| ORDERS    | 19943 |   447K|       |   123   (3)| 00:00:02 |
|*  4 |     INDEX RANGE SCAN          | PK_ORDERS | 19943 |       |       |    42   (5)| 00:00:01 |
|   5 |    TABLE ACCESS BY INDEX ROWID| ORDERS    | 49730 |  1116K|       |   303   (3)| 00:00:05 |
|*  6 |     INDEX RANGE SCAN          | PK_ORDERS | 49730 |       |       |   100   (4)| 00:00:02 |
Predicate Information (identified by operation id):
   4 - access("ID">630000 AND "ID"<650000)
   6 - access("ID">=650000)
Statistics
          1  recursive calls
          0  db block gets
        418  consistent gets
          0  physical reads
          0  redo size
    2347358  bytes sent via SQL*Net to client
      51711  bytes received via SQL*Net from client
       4668  SQL*Net roundtrips to/from client
          1  sorts (memory)
          0  sorts (disk)
      70000  rows processed

Similar Messages

  • HT5100 I changed my course description last week but it still hasn't showed up with the changes in iTunes. When you download the course it is correct. Is there something I am missing?

    I changed my course description last week but it still hasn't showed up with the changes in iTunes. When you download the course it is correct. Is there something I am missing?

    Since the maximum OS X version for an eMac is 10.5, how are you running OS X 10.7.5 on the eMac?
    http://support.apple.com/kb/TS1591

  • How can I decide the size of HANA server when using DMO of SUM ?

    Hi expert,
    I want to execute DB migration from MS SQL to SAP HANA by using DMO of SUM.
    So I have a question.
    How can I decide the size of HANA server when using DMO of SUM ?
    Now I have MS SQL in windows server.
    But in order to use HANA , I have to prepare Linux server.
    I want to know How can I decide the size of this Linux server.
    Can I expect the function of data compression in HANA ?
    Thanks in advance .
    Kazuki.

    Kazuki,
    Please take attetion:
    Your linux box already created = Application server:
    Application Server
    Based on the measurements SAP doesn't expect any changes concerning CPU, memory and network requirements for the ABAP application server. This means that the existing hardware and network infrastructure can still be used. Please check the PAM (www.service.sap.com/pam) for further details.
    SAP HANA Appliance ( porvided by your hardware partner)
    Consider SAP Note recommendation for HANA Main Memory, HANA CPU and HANA Disk Space.
    Regards,
    Edinaldo Junior

  • [svn:fx-trunk] 10545: Make DataGrid smarter about when and how to calculate the modulefactory for its renderers when using embedded fonts

    Revision: 10545
    Author:   [email protected]
    Date:     2009-09-23 13:33:21 -0700 (Wed, 23 Sep 2009)
    Log Message:
    Make DataGrid smarter about when and how to calculate the modulefactory for its renderers when using embedded fonts
    QE Notes: 2 Mustella tests fail:
    components/DataGrid/DataGrid_HaloSkin/Properties/datagrid_properties_columns_halo datagrid_properties_columns_increase0to1_halo
    components/DataGrid/DataGrid_SparkSkin/Properties/datagrid_properties_columns datagrid_properties_columns_increase0to1
    These fixes get us to measure the embedded fonts correctly when going from 0 columns to a set of columns so rowHeight will be different (and better) in those scenarios
    Doc Notes: None
    Bugs: SDK-15241
    Reviewer: Darrell
    API Change: No
    Is noteworthy for integration: No
    tests: checkintests mustella/browser/DataGrid
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-15241
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/framework/src/mx/controls/DataGrid.as
        flex/sdk/trunk/frameworks/projects/framework/src/mx/controls/dataGridClasses/DataGridBase .as
        flex/sdk/trunk/frameworks/projects/framework/src/mx/controls/dataGridClasses/DataGridColu mn.as

    Hi Matthias,
    Sorry, if this reply seems like a products plug (which it is), but this is really how we solve this software engineering challenge at JKI...
    At JKI, we create VI Packages (which are basically installers for LabVIEW instrument drivers and toolkits) of our reusable code (using the package building capabilities of VIPM Professional).  We keep a VI Package Configuration file (that includes a copy of the actual packages) in each of our project folders (and check it into source code control just as we do for all our project files).  We also use VIPM Enterprise to distribute new VI Packages over the network.
    Also, as others have mentioned, we use the JKI TortoiseSVN Tool to make it easy to use TortoiseSVN directly from LabVIEW.
    Please feel free to contact JKI if you have any specific questions about these products.
    Thanks,
    -Jim 

  • Cursor does not change to a circle when using eraser

    Cursor does not change to a circle when using the eraser.
    I'm sure it must be a tick box somewhere.
    Its always been ok previously.

    I had this same problem and was searching for answers. I also prefer using a circle instead of crosshairs. I hope you've figured it out by now, but, if you haven't, here is the answer (I am using Elements 9, but, it should work for other versions I think):
    1. Open up Elements Editor, Click on Edit, Click on Preferences, Click on Display & Cursors.
    2. Under Painting Cursors, select Full Size Brush Tip
    3. (optional) - if you want crosshairs within your circle, then also select Show Crosshair in Brush Tip.
    4. Click ok.
    Now use the brush, and it should have a circle to use.
    P.S. Sometimes if you have your Caps Lock key on, that removes the circle as well.

  • When using my ipad air it keeps coming off the page I'm on or app and going back to the home screen. Also when using my ipad the screen will go white with a black apple icon in the middle for about 20 seconds then it makes a ping

    When using my ipad air it keeps coming off the page I'm on or app I am using and going back to the home screen. Also when using my ipad the screen will go white with a black apple icon in the middle for about 20 seconds then it makes a ping sound and goes to the home screen. Could anyone help please. Thank you :-)

    Read here:
    http://help.apple.com/ipad/8/#/iPad9a245e3e

  • Is there a way to remove the blurred background wallpaper effect when using the phone in iPhone 4S' iOS 7?

    Hello.
    A few nights ago, my picky client finally upgraded his iPhone 4S' iOS 6 to iOS 7. He doesn't like the blurred background wallpaper image when using the phone feature (e.g., calling and talking). Is there a way to disable this new visual effect like in iOS 6?  I am pretty sure this is by design by Apple.
    Thank you in advance.

    sberman wrote:
    I'm not completely sure I understand, but ...
    Might Settings > General > Accessibility > Reduce Motion = "On" do what the customer wants?
    I will tell him about that, but I don't think that would be it if that is related to animation.
    We're talking about the wallpaper background that get blurry during the phone screens like http://www.tekrevue.com/wp-content/uploads/2013/09/20130923_ios7emergencycallfla w.jpg (left side) and http://i.i.cbsi.com/cnwk.1d/i/tim2/2013/09/20/ChangingYourTheme.png ... You can see there are background images that got blurred out.

  • HT1947 The gyro no longer works when using the remote app on my iPad. I updated to iOS 7.0.1. This seem to happen after the update. Any suggestions?

    The gyro no longer works when using the remote app on my iPad. I updated to iOS 7.0.1.
    This seem to happen after the update. Any suggestions?

    Dear Apple friends,
    I have the exact same problem with some apps.
    Even when I try some websites in Safari and Chrome that require loading big chunks of data they crash.
    Today it crashed in two new places. In the notification center and when I opened newstand app I no longer was able to return to the main window and the dock disappeared.
    I have my ipad retina for about three months now but latelly this issue has became more frequent. What should I do?
    Should I update to the latest firmware and do what raymond73 said?
    Is there a fix for this issue?
    Has Apple said anything about this? Because I see that this issue is happening to a lot of people.
    Is it possible to downgrade to iOS 6?
    Is it a firmware problem? That can be fixed in future releases? Or an hardware issue?
    Should I wait or go to the place I bought it and try to get the money back?

  • The settings box is always in the middle of my screen when using Flash Player , Won't close?

    The settings box is always in the middle of my screen when using Flash Player , Won't close ?

    See:How do I do a clean install of Flash Player?
    It should work ok after that.

  • How can I make the status bar hide automatically when using safari?

    How can I make the status bar hide automatically when using safari?

    When Safari is in FullScreen mode, menu bar will be hidden.
    Safari window to fit the screen?
    Move the mouse pointer to the bottom right corner of the Safari window.
    Double arrows will appear. Drag it to resize the window to fit the screen.

  • How do I set up a mail group on mac mail?  All the advise on line seems to refer to 'address book' and I only have 'contacts'.  The guidance does not work when using 'contacts' - can anyone help me?

    How do I set up a mail group on mac mail?  All the advise on line seems to refer to 'address book' and I only have 'contacts'.  The guidance does not work when using 'contacts' - can anyone help me?

    Create a group and send mail
    http://www.dummies.com/how-to/content/how-to-create-a-basic-contact-group-in-mac -os-x-li.html
    http://www.macworld.com/article/1165582/how_to_email_groups_with_mail.html
    Best.

  • What is the type of backup file when using ovi sui...

    Hi there....
    Where is the backup file usually stored when using ovi suite??
    what is the type of the file when i want to search in windows viasta???
    THANK YOU
    Solved!
    Go to Solution.

    The backup file will have a ".nbu" file extension. You can view (and edit) the default saving location by going to Tools>Options>My devices.
    Attachments:
    ovi_suite_backup.jpg ‏93 KB

  • How can i turn off all the mails that i recive when use any program form my iPad?

    How can i turn off all the mails that i recive when use any program form my iPad?

    Everytime i use the my ID recive an e Mail to inform me.

  • Can I disable the "corners" that turn down when using Parallels?

    Can I disable the "corners" that turn down when using Parallels?

    "Auto Save" is Apple's term, I guess. Its controls are so well-hidden I'm flying blind here.
    But as I put it in a note to a magazine dedicated to Apple:
    I think Auto Save is one of the dumbest things Apple has ever come up with -- oh so typical of what Bill Gates used to give people: lots of extra stuff no one ever asked for, and no one at his company ever thought through.
    Say there's a conflict with a program or two I'm trying to use. Machine locks up. I force quit and shut down -- probably without ever seeing the option of stopping Auto Save.
    When I open up again, what am I faced with? Yup, exactly the same mess I just tried to get away from.
    Boo, Apple!

  • Thin flickering white line at the very top of screen when using mail

    using an imac 27 inch, new...
    there is a thin flickering white line at the very top of screen when using mail.
    usually when sending a mail or when the cursor moves over a link ( in apple mail )
    the flickering line is just under the very top menu bar which has the date on etc...
    anyone else had this or know how to fix it?
    cheers

    I am facing the same problem. In fact mac book pro 13 retina was in the 14 day period so I got it retuned today, after directions from the apple telephone support. However, the new machine I got in exchange has the same problem or flickering line under the menu tab.
    The only relief it seems is the fact that it's not a hardware problem probably. I also think so because if I do a full screen which essentially means there is no menu bar, then there is no flickering white line.
    Hope apple fixes this. Sad to notice this drop in apple quality, and yet not fixed.

Maybe you are looking for