Better to write this query -- the UNION kills the query

Is there a better way to write this qery to avoid the union?
CREATE TABLE EMP
EMP_ID           NUMBER,
LAST_NAME     VARCHAR2(20),
FIRST_NAME     VARCHAR2(20),
MID_NAME     VARCHAR2(20)
CREATE TABLE EMP_NM
EMP_ID          NUMBER,
LAST_NAME     VARCHAR2(20),
FIRST_NAME     VARCHAR2(20),
MID_NAME     VARCHAR2(20)
INSERT INTO EMP
VALUES(
1, 'ANDERSON', 'SCOTT', NULL)
INSERT INTO EMP
VALUES
(2, 'KEVINSKY', 'KEVIN', NULL
INSERT INTO EMP_NM
VALUES(
1, 'ANDERSON', 'SCOTT', NULL)
INSERT INTO EMP_NM
VALUES(
1, 'LEE', 'SCOTT', 'K')
INSERT INTO EMP_NM
VALUES
(2, 'KEVINSKY', 'KEVIN', NULL )
INSERT INTO EMP_NM
VALUES
(2, 'ANDERSON', 'KEVIN', NULL )
SELECT
E.EMP_ID          ,
E.LAST_NAME     ,
E.FIRST_NAME     ,
E.MID_NAME                              FROM          
EMP          E          
WHERE          
E.LAST_NAME          =:LAST_NAME     
UNION
SELECT
E.EMP_ID          ,
E.LAST_NAME     ,
E.FIRST_NAME     ,
E.MID_NAME     
FROM
SELECT     EN.EMP_ID     
FROM          
     EMP_NM     EN
WHERE          
EN.LAST_NAME     =:LAST_NAME                              )          EN1 ,
EMP     E
WHERE
E.EMP_ID     =     EN1.EMP_ID

EXPLAIN PLAN without sort
SELECT STATEMENT Optimizer Mode=CHOOSE          171 K          6717                     
FILTER                                        
TABLE ACCESS FULL     EMP     171 K     5 M     6717                     
TABLE ACCESS BY INDEX ROWID     EMP_NM     1      14      1                     
INDEX RANGE SCAN     IDXEMP_ID     1           3
EXPLIAN PLAN WITH SORT
     Operation     Object Name     Rows     Bytes     Cost     Object Node     In/Out     PStart     PStop
SELECT STATEMENT Optimizer Mode=CHOOSE          171 K          7658                     
SORT ORDER BY          171 K     5 M     7658                     
FILTER                                        
TABLE ACCESS FULL     EMP     171 K     5 M     6717                     
TABLE ACCESS BY INDEX ROWID     EMP_NM     1      14      1                     
INDEX RANGE SCAN     IDXEMP_ID     1           3

Similar Messages

  • Does the union improves the performance?

    Hi all,
    I would like to know does the union in sql or pl/sql optimizes the performance of the query? here we are retreiveing the data from a remote databse to see about 3700 hundred records it took on oracle 9i 40 seconds to get, where as when we added the union its retriving the data in 2 seconds does the union has anything to do with backend in pl/sql to optimize this query.
    CURSOR ecur IS
    SELECT 0 id,' No PO' name,'' dir,'' SYMBOL,'' PHONE,'' EMAIL FROM dual
    UNION
    SELECT id,name,DIR,SYMBOL,PHONE,EMAIL
    FROM [email protected]
    WHERE dir IN ('A','C','W','V','S','SA','H')
    AND name LIKE initcap(match)||'%'
    ORDER BY name;
    before added the union select statement it took 40 seconds after i added the union its taking 2 seconds.. so i want to know the difference between these two statements why so much difference in performance.
    please do help me out...
    Thanks a lot.....

    Do an explain plan of the two queries. Chances are the optimizer decided to use a different plan for the main query when you unioned it with dual.

  • Plugging Blackberry into the computer kills the battery

    Last night, I plugged in my phone to do a backup, it had about 50% of it's battery left.  After I had completed the backup, maybe an hour, I unplugged it, and the plug icon flashed briefly on the screen and then the phone shut off (like it had no power).  The phone refused to turn on, it just flashed the dead battery icon.  I swapped the battery with another one, and put the phone back on the computer to try to backup the media on the SIM card.  This morning when I unplugged it from the computer, same thing: the plug icon flashed briefly, and the phone refused to turn on because it's battery was dead.
    Right now I have it plugged into the Blackberry charger and it's charging from flat, like from 6% up.
    The batteries are authentic RIM logoed batteries, the charger too, though I think the cable to the computer isn't (but how could that matter?).
    What is going on?  It shouldn't kill it's battery connecting to the computer, and certainly not in an hour.
    Thanks,
    Stephane

    It sounds like to me your USB port is not powered the level required for charging the device.
    Do you have an original wall outlet charger?
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • How to hide one of the unions from the results?

    Hi all,
    I have a graph which contains 5 unions. The top query is used to pass the functions and the other 4 are the ones that really doing the caclutaions. Is there any way to hid one query from results?
    Thanks in advance.

    Hiding based on what? If it is a prompt, assign a presentation variable and add a condition to the filter of your desirable result-set in a structure like:
    CASE WHEN '@{myPresentationVariable}{DefaultValue}' = 'WhateverValueIWant' THEN 1 ELSE 0 END = 1

  • Why won't Firefox install after I've downloaded the latest version? I can't get it to open. I have it on Mac with OSX system. It worked before the storm killed the power but now it won't open up at all, using the same methods I used before.

    My power was shut off due to a storm. When I fired up my Mac, the Fox was nowhere to be found.

    This issue can be caused by corrupted cookies.
    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    * Firefox > Preferences > Advanced > Network > Offline Storage (Cache): "Clear Now"
    "Remove Cookies" from sites causing problems:
    * Firefox > Preferences > Privacy > Cookies: "Show Cookies"
    * http://kb.mozillazine.org/Menu_differences
    *Windows: Firefox (Tools) > Options
    *Mac: Firefox > Preferences
    *Linux: Edit > Preferences

  • How the Leopard Killed the Tiger

    Today I thought I'd take my work machine (G5) and install Leopard on a second internal drive while the top drive would not be effected and continue running Tiger and all my wares. All I'd have to is hold the option key on boot and select the appropriate OS. Well it didn't quite work out that way.
    The first thing I did was install Tiger on the second drive just to make sure that I could do as above. Worked great. Then I installed Leo after all of Tigers updates. Worked fine...until I attempted to restart into Tiger, on the original top drive, and all it did after the initial boot was shutdown. Tried to boot again and same thing...shutdown. Then I ran Disk Utitity/Repair Disk from my Tiger disk and it said that there were serious errors ("Keys out of order. Rebuilding Catalog B Tree. The Volume XXXX could not be repaired". Why I wondered, I never touched that drive. How did installing on one drive affect the other?
    Took the second drive (Leo) out and still have the same problem. Zapped the PRAM, nada. I hope an updated, new copy (42) of DW can fix things.
    BTW, The only option I have available in DU is to reformat the drive. The drive is not available to do a fresh system install.
    Any other suggestions other than DW?
    Thanks for any help

    Ran DW this morning. The first attempt failed when the system locked up, so I gave it another try and then she fixed lots of errors:
    DiskWarrior Report:
    • All errors in the directory structure such as tree depth, header node, map nodes, node size, node counts, node links, indexes and more have been repaired.
    • 9 files had to be recovered. The files may have been lost or thrown away. You must inspect the files to determine the extent of any damage. You must also determine whether the files should be discarded.
    • 2 files had a directory entry with an incorrect flag that was repaired.
    • 2 files had an ID that was repaired.
    • 18 files had a directory entry with an incorrect text encoding value that was repaired.
    • 1 file had a directory entry with an incorrect starting allocation value that was repaired. You must inspect the file to determine the extent of any damage. The detailed view of this report lists the file.
    • 3 files had a duplicate name that was repaired.
    • 1 file had an incorrect actual size that was repaired.
    • 2 files had an incorrect key that was repaired.
    • 1 file had to be moved to the "Damaged Items" folder.
    • 5 folders had an incorrect item count that was repaired.
    • 2 folders had a directory entry with an incorrect custom icon flag that was repaired.
    • 2 files/folders had to be moved to the "Rescued Items" folder.
    • Incorrect values in the Volume Information were repaired.
    • Critical values in the Volume Information were incorrect and were repaired.
    Disk Information:
    Files: 358,451
    Folders: 86,246
    Free Space: 189.62 GB
    Format: Mac OS Extended (Journaled)
    Block Size: 4 K
    Disk Sectors: 489,972,528
    Media: Maxtor 6Y250M0
    Time: 3/17/08 5:19:31 AM
    So I'm up and running great as far as I can tell. All I can say is this is the hardest I've been down where DW has truly come to the rescue. Keep in mind that my system wouldn't even boot. I'll be ordering my update this week. I do not work for Alsoft, so don't consider this spam.
    Tony

  • Picking up the phone, kills the internet.

    I've had DSL for about two years now with Verizon, the same box, but this year, I'm having internet problems. Everytime I pick up the phone, the internet goes out. And it's so annoying!!! I have the Westell 6100. What's the solution to this, new modem? It's very frustrating. I don't know what else to do. I would really appreaciate the help.
    Thank you.

    The first thing you do is make sure that all of your micro-filters are in place and installed correctly. This includes all telephone jacks, alarm systems, fax machines and computer modems hooked up to the DSL telephone number. If you did all that and the problem remains there is something wrong with the line itself and you will need to call DSL repair.

  • Whats wrong with the UNION ALL

    Hi All
    I have the following table and data
    WITH sample_data AS
         (SELECT '1' AS bin_data_id, '539' AS traffic_sample_id,
                 '1100' AS end_intv_time, '0' AS bin_1_data, '34' AS bin_2_data,
                 '19' AS bin_3_data
            FROM DUAL
          UNION ALL
          SELECT '2', '539', '1200', '0', '65', '18'
            FROM DUAL
          UNION ALL
          SELECT '3', '539', '1300', '0', '51', '17'
            FROM DUAL
          UNION ALL
          SELECT '4', '539', '1400', '0', '65', '27'
            FROM DUAL
          UNION ALL
          SELECT '5', '539', '1500', '0', '99', '48'
            FROM DUAL
          UNION ALL
          SELECT '6', '539', '1600', '0', '426', '138'
            FROM DUAL
          UNION ALL
          SELECT '7', '539', '1700', '0', '151', '62'
            FROM DUAL
          UNION ALL
          SELECT '8', '539', '1800', '0', '80', '32'
            FROM DUAL
          UNION ALL
          SELECT '9', '539', '1900', '0', '31', '11'
            FROM DUAL
          UNION ALL
          SELECT '10', '539', '2000', '0', '37', '11'
            FROM DUAL
          UNION ALL
          SELECT '11', '539', '2100', '0', '24', '9'
            FROM DUAL
          UNION ALL
          SELECT '12', '539', '2200', '0', '16', '5'
            FROM DUAL
          UNION ALL
          SELECT '13', '539', '2300', '0', '27', '12'
            FROM DUAL
          UNION ALL
          SELECT '14', '539', '2400', '0', '55', '20'
            FROM DUAL
          UNION ALL
          SELECT '15', '539', '0100', '0', '18', '9'
            FROM DUAL
          UNION ALL
          SELECT '16', '539', '0200', '0', '134', '52'
            FROM DUAL
          UNION ALL
          SELECT '17', '539', '0300', '0', '230', '69'
            FROM DUAL
          UNION ALL
          SELECT '18', '539', '0400', '0', '15', '7'
            FROM DUAL
          UNION ALL
          SELECT '19', '539', '0500', '0', '6', '5'
            FROM DUAL
          UNION ALL
          SELECT '20', '539', '0600', '0', '47', '23'
            FROM DUAL
          UNION ALL
          SELECT '21', '539', '0700', '0', '100', '41'
            FROM DUAL
          UNION ALL
          SELECT '22', '539', '0800', '0', '196', '43'
            FROM DUAL
          UNION ALL
          SELECT '23', '539', '0900', '0', '81', '20'
            FROM DUAL
          UNION ALL
          SELECT '24', '539', '1000', '0', '58', '28'
            FROM DUAL
          UNION ALL
          SELECT '25', '539', '1100', '0', '58', '24'
            FROM DUAL
          UNION ALL
          SELECT '26', '539', '1200', '0', '60', '22'
            FROM DUAL
          UNION ALL
          SELECT '27', '539', '1300', '0', '42', '18'
            FROM DUAL
          UNION ALL
          SELECT '28', '539', '1400', '0', '53', '15'
            FROM DUAL
          UNION ALL
          SELECT '29', '539', '1500', '0', '107', '43'
            FROM DUAL
          UNION ALL
          SELECT '30', '539', '1600', '0', '441', '146'
            FROM DUAL
          UNION ALL
          SELECT '31', '539', '1700', '0', '128', '34'
            FROM DUAL
          UNION ALL
          SELECT '32', '539', '1800', '0', '67', '27'
            FROM DUAL
          UNION ALL
          SELECT '33', '539', '1900', '0', '45', '22'
            FROM DUAL
          UNION ALL
          SELECT '34', '539', '2000', '0', '24', '13'
            FROM DUAL
          UNION ALL
          SELECT '35', '539', '2100', '0', '16', '11'
            FROM DUAL
          UNION ALL
          SELECT '36', '539', '2200', '0', '28', '5'
            FROM DUAL
          UNION ALL
          SELECT '37', '539', '2300', '0', '23', '8'
            FROM DUAL
          UNION ALL
          SELECT '38', '539', '2400', '0', '73', '11'
            FROM DUAL
          UNION ALL
          SELECT '39', '539', '0100', '0', '16', '3'
            FROM DUAL
          UNION ALL
          SELECT '40', '539', '0200', '0', '243', '82'
            FROM DUAL
          UNION ALL
          SELECT '41', '539', '0300', '0', '121', '55'
            FROM DUAL
          UNION ALL
          SELECT '42', '539', '0400', '0', '17', '4'
            FROM DUAL
          UNION ALL
          SELECT '43', '539', '0500', '0', '5', '5'
            FROM DUAL
          UNION ALL
          SELECT '44', '539', '0600', '0', '41', '15'
            FROM DUAL
          UNION ALL
          SELECT '45', '539', '0700', '0', '101', '34'
            FROM DUAL
          UNION ALL
          SELECT '46', '539', '0800', '0', '184', '43'
            FROM DUAL
          UNION ALL
          SELECT '47', '539', '0900', '0', '69', '15'
            FROM DUAL
          UNION ALL
          SELECT '48', '539', '1000', '0', '51', '18'
            FROM DUAL
          UNION ALL
          SELECT '49', '539', '1100', '0', '61', '25'
            FROM DUAL)
    SELECT *
      FROM sample_data;Now i have 2 queries , the one below query is to just get the last bin_data_id per each traffic_sample_id
    SELECT ROW_NUMBER () OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id)
                                                                            AS rn_1,
           COUNT (bin_data_id) OVER (PARTITION BY traffic_sample_id) AS cnt_1,TRAFFIC_SAMPLE_ID,bin_data_id,(END_INTV_TIME_1+100) AS END_INTV_TIME,BIN_1_DATA,BIN_2_DATA,BIN_3_DATA
      FROM
    SELECT ROW_NUMBER() OVER(ORDER BY TRAFFIC_SAMPLE_ID) AS RN,traffic_sample_id,
           end_intv_time,
           last_value(end_intv_time) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
                                                                            AS END_INTV_TIME_1,
           LAST_VALUE (bin_data_id) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
                                                                            AS bin_data_id,
           LAST_VALUE (bin_1_data) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
                                                                            AS bin_1_data,
           LAST_VALUE (bin_2_data) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
                                                                            AS bin_2_data,
           LAST_VALUE (bin_3_data) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
                                                                            AS bin_3_data
      FROM bin_data
      WHERE RN=BIN_DATA_ID
      and traffic_sample_id=539And now i'm doing the UNION ALL the above query with a different query as below
    select rn_1,cnt_1,traffic_sample_id, bin_data_id, to_number(end_intv_time),bin_1_data,bin_2_data,bin_3_data
    from
    select ROW_NUMBER () OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id)
                                                                            AS rn_1,
           COUNT (bin_data_id) OVER (PARTITION BY traffic_sample_id) AS cnt_1,
           traffic_sample_id, bin_data_id, end_intv_time, direction,bin_1_data,bin_2_data,bin_3_data
           from
    SELECT ROW_NUMBER () OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id)
                                                                            AS rn,
           COUNT (bin_data_id) OVER (PARTITION BY traffic_sample_id) AS cnt,
           traffic_sample_id, bin_data_id, end_intv_time, direction,bin_1_data,bin_2_data,bin_3_data
      FROM bin_data
      where rn!=1
      where traffic_sample_id=539
      union all
      SELECT ROW_NUMBER () OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id)
                                                                            AS rn_1,
           COUNT (bin_data_id) OVER (PARTITION BY traffic_sample_id) AS cnt_1,TRAFFIC_SAMPLE_ID,bin_data_id,(END_INTV_TIME_1+100) AS END_INTV_TIME,BIN_1_DATA,BIN_2_DATA,BIN_3_DATA
      FROM
    SELECT ROW_NUMBER() OVER(ORDER BY TRAFFIC_SAMPLE_ID) AS RN,traffic_sample_id,
           end_intv_time,
           last_value(end_intv_time) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
                                                                            AS END_INTV_TIME_1,
           LAST_VALUE (bin_data_id) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
                                                                            AS bin_data_id,
           LAST_VALUE (bin_1_data) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
                                                                            AS bin_1_data,
           LAST_VALUE (bin_2_data) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
                                                                            AS bin_2_data,
           LAST_VALUE (bin_3_data) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
                                                                            AS bin_3_data
      FROM bin_data
      WHERE RN=BIN_DATA_ID
      and traffic_sample_id=539Now all works fine and appends the single record to the set of records and i get the following data set.
    RN_1     CNT_1     TRAFFIC_SAMPLE_ID     BIN_DATA_ID     TO_NUMBER(END_INTV_TIME)     BIN_1_DATA     BIN_2_DATA     BIN_3_DATA
    1     48     539     2     1200     0     65     18
    2     48     539     3     1300     0     51     17
    3     48     539     4     1400     0     65     27
    4     48     539     5     1500     0     99     48
    5     48     539     6     1600     0     426     138
    6     48     539     7     1700     0     151     62
    7     48     539     8     1800     0     80     32
    8     48     539     9     1900     0     31     11
    9     48     539     10     2000     0     37     11
    10     48     539     11     2100     0     24     9
    11     48     539     12     2200     0     16     5
    12     48     539     13     2300     0     27     12
    13     48     539     14     2400     0     55     20
    14     48     539     15     100     0     18     9
    15     48     539     16     200     0     134     52
    16     48     539     17     300     0     230     69
    17     48     539     18     400     0     15     7
    18     48     539     19     500     0     6     5
    19     48     539     20     600     0     47     23
    20     48     539     21     700     0     100     41
    21     48     539     22     800     0     196     43
    22     48     539     23     900     0     81     20
    23     48     539     24     1000     0     58     28
    24     48     539     25     1100     0     58     24
    25     48     539     26     1200     0     60     22
    26     48     539     27     1300     0     42     18
    27     48     539     28     1400     0     53     15
    28     48     539     29     1500     0     107     43
    29     48     539     30     1600     0     441     146
    30     48     539     31     1700     0     128     34
    31     48     539     32     1800     0     67     27
    32     48     539     33     1900     0     45     22
    33     48     539     34     2000     0     24     13
    34     48     539     35     2100     0     16     11
    35     48     539     36     2200     0     28     5
    36     48     539     37     2300     0     23     8
    37     48     539     38     2400     0     73     11
    38     48     539     39     100     0     16     3
    39     48     539     40     200     0     243     82
    40     48     539     41     300     0     121     55
    41     48     539     42     400     0     17     4
    42     48     539     43     500     0     5     5
    43     48     539     44     600     0     41     15
    44     48     539     45     700     0     101     34
    45     48     539     46     800     0     184     43
    46     48     539     47     900     0     69     15
    47     48     539     48     1000     0     51     18
    48     48     539     49     1100     0     61     25
    1     1     539     49     1200     0     61     25But please help me , all the above queries are working fine when i check by traffic_sample_id, for example if i remove the WHERE CLAUSE, WHERE TRAFFIC_SAMPLE_ID=539 from both the queries in the UNION ALL to get all the TRAFFIC_SAMPLE_ID's the single records are not getting appended to the resultant data set. Please need help.
    Thanks

    Please consider the following sample data
    WITH sample_data AS
         (SELECT '1' AS bin_data_id, '539' AS traffic_sample_id,
                 '1100' AS end_intv_time, '0' AS bin_1_data, '34' AS bin_2_data,
                 '19' AS bin_3_data
            FROM DUAL
          UNION ALL
          SELECT '2', '539', '1200', '0', '65', '18'
            FROM DUAL
          UNION ALL
          SELECT '3', '539', '1300', '0', '51', '17'
            FROM DUAL
          UNION ALL
          SELECT '4', '539', '1400', '0', '65', '27'
            FROM DUAL
          UNION ALL
          SELECT '5', '539', '1500', '0', '99', '48'
            FROM DUAL
          UNION ALL
          SELECT '6', '539', '1600', '0', '426', '138'
            FROM DUAL
          UNION ALL
          SELECT '7', '539', '1700', '0', '151', '62'
            FROM DUAL
          UNION ALL
          SELECT '8', '539', '1800', '0', '80', '32'
            FROM DUAL
          UNION ALL
          SELECT '9', '539', '1900', '0', '31', '11'
            FROM DUAL
          UNION ALL
          SELECT '10', '539', '2000', '0', '37', '11'
            FROM DUAL
          UNION ALL
          SELECT '11', '539', '2100', '0', '24', '9'
            FROM DUAL
          UNION ALL
          SELECT '12', '539', '2200', '0', '16', '5'
            FROM DUAL
          UNION ALL
          SELECT '13', '539', '2300', '0', '27', '12'
            FROM DUAL
          UNION ALL
          SELECT '14', '539', '2400', '0', '55', '20'
            FROM DUAL
          UNION ALL
          SELECT '15', '539', '0100', '0', '18', '9'
            FROM DUAL
          UNION ALL
          SELECT '16', '539', '0200', '0', '134', '52'
            FROM DUAL
          UNION ALL
          SELECT '17', '539', '0300', '0', '230', '69'
            FROM DUAL
          UNION ALL
          SELECT '18', '539', '0400', '0', '15', '7'
            FROM DUAL
          UNION ALL
          SELECT '19', '539', '0500', '0', '6', '5'
            FROM DUAL
          UNION ALL
          SELECT '20', '539', '0600', '0', '47', '23'
            FROM DUAL
          UNION ALL
          SELECT '21', '539', '0700', '0', '100', '41'
            FROM DUAL
          UNION ALL
          SELECT '22', '539', '0800', '0', '196', '43'
            FROM DUAL
          UNION ALL
          SELECT '23', '539', '0900', '0', '81', '20'
            FROM DUAL
          UNION ALL
          SELECT '24', '539', '1000', '0', '58', '28'
            FROM DUAL
          UNION ALL
          SELECT '25', '539', '1100', '0', '58', '24'
            FROM DUAL
          UNION ALL
          SELECT '26', '539', '1200', '0', '60', '22'
            FROM DUAL
          UNION ALL
          SELECT '27', '539', '1300', '0', '42', '18'
            FROM DUAL
          UNION ALL
          SELECT '28', '539', '1400', '0', '53', '15'
            FROM DUAL
          UNION ALL
          SELECT '29', '539', '1500', '0', '107', '43'
            FROM DUAL
          UNION ALL
          SELECT '30', '539', '1600', '0', '441', '146'
            FROM DUAL
          UNION ALL
          SELECT '31', '539', '1700', '0', '128', '34'
            FROM DUAL
          UNION ALL
          SELECT '32', '539', '1800', '0', '67', '27'
            FROM DUAL
          UNION ALL
          SELECT '33', '539', '1900', '0', '45', '22'
            FROM DUAL
          UNION ALL
          SELECT '34', '539', '2000', '0', '24', '13'
            FROM DUAL
          UNION ALL
          SELECT '35', '539', '2100', '0', '16', '11'
            FROM DUAL
          UNION ALL
          SELECT '36', '539', '2200', '0', '28', '5'
            FROM DUAL
          UNION ALL
          SELECT '37', '539', '2300', '0', '23', '8'
            FROM DUAL
          UNION ALL
          SELECT '38', '539', '2400', '0', '73', '11'
            FROM DUAL
          UNION ALL
          SELECT '39', '539', '0100', '0', '16', '3'
            FROM DUAL
          UNION ALL
          SELECT '40', '539', '0200', '0', '243', '82'
            FROM DUAL
          UNION ALL
          SELECT '41', '539', '0300', '0', '121', '55'
            FROM DUAL
          UNION ALL
          SELECT '42', '539', '0400', '0', '17', '4'
            FROM DUAL
          UNION ALL
          SELECT '43', '539', '0500', '0', '5', '5'
            FROM DUAL
          UNION ALL
          SELECT '44', '539', '0600', '0', '41', '15'
            FROM DUAL
          UNION ALL
          SELECT '45', '539', '0700', '0', '101', '34'
            FROM DUAL
          UNION ALL
          SELECT '46', '539', '0800', '0', '184', '43'
            FROM DUAL
          UNION ALL
          SELECT '47', '539', '0900', '0', '69', '15'
            FROM DUAL
          UNION ALL
          SELECT '48', '539', '1000', '0', '51', '18'
            FROM DUAL
          UNION ALL
          SELECT '49', '539', '1100', '0', '61', '25'
            FROM DUAL
          UNION ALL
          SELECT '11033', '613','1300','3','421','124'
            FROM DUAL
          UNION ALL
          SELECT '11034', '613', '1400', '4', '419', '128'
            FROM DUAL
          UNION ALL
          SELECT '11035', '613', '1500', '5', '522', '169'
            FROM DUAL
          UNION ALL
          SELECT '11036', '613', '1600', '5', '596', '185'
            FROM DUAL
          UNION ALL
          SELECT '11037', '613', '1700', '9', '667', '150'
            FROM DUAL
          UNION ALL
          SELECT '11038', '613', '1800', '4', '522', '105'
            FROM DUAL
          UNION ALL
          SELECT '11039', '613', '1900', '2', '428', '80'
            FROM DUAL
          UNION ALL
          SELECT '11040', '613', '2000', '5', '304', '73'
            FROM DUAL
          UNION ALL
          SELECT '11041', '613', '2100', '1', '284', '61'
            FROM DUAL
          UNION ALL
          SELECT '11042', '613', '2200', '3', '245', '45'
            FROM DUAL
          UNION ALL
          SELECT '11043', '613', '2300', '6', '193', '39'
            FROM DUAL
          UNION ALL
          SELECT '11044', '613', '2400', '0', '109', '23'
            FROM DUAL
          UNION ALL
          SELECT '11045', '613', '0100', '0', '81', '25'
            FROM DUAL
          UNION ALL
          SELECT '11046', '613', '0200', '0', '56', '24'
            FROM DUAL
          UNION ALL
          SELECT '11047', '613', '0300', '0', '62', '11'
            FROM DUAL
          UNION ALL
          SELECT '11048', '613', '0400', '0', '59', '27'
            FROM DUAL
          UNION ALL
          SELECT '11049', '613', '0500', '1', '180', '87'
            FROM DUAL
          UNION ALL
          SELECT '11050', '613', '0600', '4', '410', '126'
            FROM DUAL
          UNION ALL
          SELECT '11051', '613', '0700', '6', '454', '138'
            FROM DUAL
          UNION ALL
          SELECT '11052', '613', '0800', '4', '393', '145'
            FROM DUAL
          UNION ALL
          SELECT '11053', '613', '0800', '4', '357', '131'
            FROM DUAL
          UNION ALL
          SELECT '11054', '613', '0900', '5', '347', '126'
            FROM DUAL
          UNION ALL
          SELECT '11055', '613', '1000', '3', '368', '155'
            FROM DUAL
          UNION ALL
          SELECT '11056', '613', '1100', '2', '384', '153'
            FROM DUAL
          UNION ALL
          SELECT '11057', '613', '1200', '7', '423', '166'
            FROM DUAL
          UNION ALL
          SELECT '11058', '613', '1300', '9', '489', '213'
            FROM DUAL
          UNION ALL
          SELECT '11059', '613', '1400', '5', '576', '190'
            FROM DUAL
          UNION ALL
          SELECT '11060', '613', '1500', '11', '712', '189'
            FROM DUAL
          UNION ALL
          SELECT '11061', '613', '1600', '9', '634', '211'
            FROM DUAL
          UNION ALL
          SELECT '11062', '613', '1700', '3', '501', '114'
            FROM DUAL
          UNION ALL
          SELECT '11063', '613', '1800', '2', '411', '117'
            FROM DUAL
          UNION ALL
          SELECT '11064', '613', '1900', '5', '291', '99'
            FROM DUAL
          UNION ALL
          SELECT '11065', '613', '2000', '1', '276', '71'
            FROM DUAL
          UNION ALL
          SELECT '11066', '613', '2100', '2', '214', '56'
            FROM DUAL
          UNION ALL
          SELECT '11067', '613', '2200', '3', '166', '46'
            FROM DUAL
          UNION ALL
          SELECT '11068', '613', '2300', '0', '99', '26'
            FROM DUAL
          UNION ALL
          SELECT '11069', '613', '2400', '0', '65', '19'
            FROM DUAL
          UNION ALL
          SELECT '11070', '613', '0100', '1', '57', '14'
            FROM DUAL
          UNION ALL
          SELECT '11071', '613', '0200', '0', '55', '15'
            FROM DUAL
          UNION ALL
          SELECT '11072', '613', '0300', '0', '49', '22'
            FROM DUAL
          UNION ALL
          SELECT '11073', '613', '0400', '3', '151', '113'
            FROM DUAL
          UNION ALL
          SELECT '11074', '613', '0500', '2', '324', '145'
            FROM DUAL
          UNION ALL
          SELECT '11075', '613', '0600', '5', '342', '161'
            FROM DUAL
          UNION ALL
          SELECT '11076', '613', '0700', '3', '294', '186'
            FROM DUAL
          UNION ALL
          SELECT '11077', '613', '0800', '6', '303', '171'
            FROM DUAL
          UNION ALL
          SELECT '11078', '613', '0900', '4', '278', '158'
            FROM DUAL
          UNION ALL
          SELECT '11079', '613', '1000', '2', '309', '156'
            FROM DUAL
          UNION ALL
          SELECT '11080', '613', '1100', '0', '51', '18'
            FROM DUAL
          UNION ALL
          SELECT '11081', '613', '1200', '0', '61', '25'
            FROM DUAL)
    SELECT *
      FROM sample_data;Here when i say the LAST(BIN_DATA_ID) i meant the last BIN_DATA_ID PER EACH TRAFFIC SAMPLE ID. What i was trying to do is in the bottom query i'm getting the LAST BIN_DATA_ID for each TRAFFIC SAMPLE ID and appending it to the top query.
    Thanks

  • Blob in the union

    hi.
    i m trying te use the union with the query which has blob column.The query works fine with out union but with union it gave me error inconsistant data type.

    > but there must be a alternative solution. ???????
    The success (or lack thereof) of any solution depends entirely on the Problem Statement.
    What you have shown us is your solution (to an unknown problem) that attempts a MINUS operation on a BLOB. A flawed solution as you've discovered.
    What you have not given us is the Problem that you are trying to solve.
    If you would like us to provide "alternatives", then you need to state The Problem.

  • Has anyone figured out how to stop the 1022 from killing the spooler?

    It used to be that when I'd print a PPT the spooler would crash and then none of my devices/printers worked.  I never happened when the 1022 was unplugged.
    Now, the 1022 kills the spooler as soon as I install it.    I've see a number of discussions but no solution yet.  I could really use some help.
    Thanks.

    Not yet....
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • For all entries changes the order of the itab

    Hi Experts
                 In the following query i have used two internal tables namely it_first and it_zlist.
                The material inwhich the it_zlist is different sorting order
          After executing this query, the order of the material inwhich the it_first is different from the it_zlist.
                 What could be the reason, pls explain me on this.
    select matnr test zsno ztnam from zmaster1
                into corresponding fields of table it_first
                      for all entries in it_zlist
                      where matnr = it_zlist-matnr.
    Thanks in advance.
    Regards
    Rajaram

    for all entries u should specified all primary key.
    sort by u condition.
    Effect
    If the addition FOR ALL ENTRIES is specified before the language element WHERE, then the components comp of the internal table itab can be used as operands when comparing with relational operators.
    The internal table itab must have a structured line type and the component comp must be compatible with the column col.
    The logical expression sql_cond of the WHERE condition can comprise various logical expressions by using AND and OR. However, if FOR ALL ENTRIES is specified, there must be at least one Comparison with a column of the internal table itab, which can be specified either statistically or dynamically (Release 6.40 and higher). In a statement with a SELECTstatement with FOR ALL ENTRIES, the addition ORDER BY can only be used with the addition PRIMARY KEY.
    The whole logical expression sql_cond is evaluated for each individual line of the internal table itab. The resulting set of the SELECT statement is the union of the resulting sets from the individual evaluations. Duplicate lines are automatically removed from the resulting set. If the internal table itab is empty, the whole WHERE statement is ignored and all lines in the database are put in the resulting set.
    Notes
    In Release 6.10 and higher, the same internal table can be specified after FOR ALL ENTRIES and after INTO.
    The addition FOR ALL ENTRIES is only possible before WHERE conditions of the SELECT statement.
    If the additions PACKAGE SIZE or UP TO n ROWS are specified together with FOR ALL ENTRIES, they are not passed to the database system but are applied instead to the resulting set once all selected rows on the application server have been imported.
    With duplicated rows in the resulting set, the addition FOR ALL ENTRIES has the same effect as if addition DISTINCT were specified in the definition of the selection quantity. Unlike DISTINCT, the rows are not deleted from the database system but are deleted on the application server from the resulting set.
    Addition FOR ALL ENTRIES is only possible for WHERE conditions of the SELECT statement.
    Example
    Exporting all flight data for a specified departure city. The relevant airlines and flight numbers are first put in an internal table entry_tab, which is evaluated in the WHERE condition of the subsquent SELECT statement.

  • Why a table full scan when I've got the PK in the WHERE clause?

    There is a very complex query that I need to optimize in an Oracle 10gR2 environment. I am deconstructing it into layers to see what is causing the first bottleneck. The innermost portion is fine, with an explain plan cost of 54. With a typical value for the bind variable, it returns 125 zero_id values. There are over 100,000 rows in table T_ONE in my test database, but my customer has over one million rows in their production instance.
                  WITH t_merged_id AS (SELECT DISTINCT zero_id FROM t_zero WHERE NVL(column2, zero_id) = :i_id)
                  SELECT   t_one.one_id
                      FROM t_one
                          INNER JOIN t_two
                              ON t_one.column1 = t_two.two_id
                          INNER JOIN t_merged_id
                              ON t_two.column10 = t_merged_id.zero_id
                  UNION ALL
                  SELECT   t_one.one_id
                      FROM t_one
                          INNER JOIN t_two
                              ON t_one.column2 = t_two.two_id
                          INNER JOIN t_merged_id
                              ON t_two.column10 = t_merged_id.zero_id
                  UNION ALL
                  SELECT   t_one.one_id
                      FROM t_one
                          INNER JOIN t_three
                              ON t_one.column3 = t_three.three_id
                          INNER JOIN t_merged_id
                              ON t_three.column10 = t_merged_id.zero_id
                  UNION ALL
                  SELECT   t_one.one_id
                      FROM t_one
                          INNER JOIN t_four
                              ON t_one.column4 = t_four.four_id
                          INNER JOIN t_two
                              ON t_four.column1 = t_two.two_id
                          INNER JOIN t_merged_id
                              ON t_two.two_id = t_merged_id.zero_id
                  UNION ALL
                  SELECT   t_one.one_id
                      FROM t_one INNER JOIN t_merged_id ON t_one.column5 = t_merged_id.zero_id
                  UNION
                  SELECT   t_one.one_id
                      FROM t_one INNER JOIN t_merged_id ON t_one.column6 = t_merged_id.zero_idHowever, the next step is to obtain a bunch of columns from T_ONE for each of those ONE_ID values. Adding that looks like the following, which causes a table full scan on T_ONE (and an explain plan cost over 1,500 for this query in my test system) and it takes far too long to return the results.
    SELECT   t_one.*
        FROM     t_one
             INNER JOIN
                 (--This is the start of the query shown above
                  WITH t_merged_id AS (SELECT DISTINCT zero_id FROM t_zero WHERE NVL(column2, zero_id) = :i_id)
                  SELECT   t_one.one_id
                      FROM t_one
                          INNER JOIN t_two
                              ON t_one.column1 = t_two.two_id
                          INNER JOIN t_merged_id
                              ON t_two.column10 = t_merged_id.zero_id
                  UNION ALL
                  SELECT   t_one.one_id
                      FROM t_one
                          INNER JOIN t_two
                              ON t_one.column2 = t_two.two_id
                          INNER JOIN t_merged_id
                              ON t_two.column10 = t_merged_id.zero_id
                  UNION ALL
                  SELECT   t_one.one_id
                      FROM t_one
                          INNER JOIN t_three
                              ON t_one.column3 = t_three.three_id
                          INNER JOIN t_merged_id
                              ON t_three.column10 = t_merged_id.zero_id
                  UNION ALL
                  SELECT   t_one.one_id
                      FROM t_one
                          INNER JOIN t_four
                              ON t_one.column4 = t_four.four_id
                          INNER JOIN t_two
                              ON t_four.column1 = t_two.two_id
                          INNER JOIN t_merged_id
                              ON t_two.two_id = t_merged_id.zero_id
                  UNION ALL
                  SELECT   t_one.one_id
                      FROM t_one INNER JOIN t_merged_id ON t_one.column5 = t_merged_id.zero_id
                  UNION
                  SELECT   t_one.one_id
                      FROM t_one INNER JOIN t_merged_id ON t_one.column6 = t_merged_id.zero_id
                   --This is the end of the query shown above
                   ) t_list
             ON t_one.one_id = t_list.one_idMy question is, why wouldn’t Oracle use the existing index PK_T_ONE, which is keyed on T_ONE.ONE_ID? I tried refactoring the query using a “WHERE t_one.one_id IN” construct instead of the INNER JOIN but it didn’t make any difference. Neither did adding an index hint, which I hoped would force the use of the PK index.
    Any ideas?

    I was able to completely resolve my problem, but I still want to understand why the original query wouldn't use an index.
    (My solution was to move all the joins and where clauses from the query that wrapped the one we've been discussing and put them into each SELECT in the UNION, so there is no longer any inner subquery. So instead of trying to first get a list of ID values from the subquery, get the full records for the IDs from an outer query, and then joining to the outer query, I made SELECT in the UNION contain the full logic. This makes the query a lot more verbose, because all the joins and wheres are repeated six times, but it does use the index and returns in 0.04 seconds instead of over nine minutes in my test database.)
    hoek wrote:
    Values for optimizer_index_caching and optimizer_index_cost_adj are not the defaults. Any reasons for that?I am not a DBA and have no idea. However, I did a Google search and found this: http://decipherinfosys.wordpress.com/2007/02/13/optimizer_index_cost_adj-and-optimizer_index_caching/. Apparently Tom Kyte would approve more of our settings than the defaults.
    hoek wrote:
    Any chance to get a realistic dataset on your test server?Unfortunately, not for quite some time. The customer won't provide any real data, and generating data for testing is complex because of all the interrelationships. I have someone working on that. However, I was able to get back on the primary test server that has 136k records in the main table instead of only 2k. So far as I know, the Oracle configuration between the test server and the customer's server is the same. However, they have much more serious hardware that I do (more processors, more RAM, more platters). On the other hand, they have 10 times as much data.
    hoek wrote:
    Your second execution plan contains differents stats, they're not the 'common ones'. (E-rows etc.)The predicates are the same as the first. The 2nd plan was generated by the 10g-specific portion of Randolph's script using the command "select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));".
    This is the result from running the script on the main test server:
    NAME                                 TYPE                             VALUE
    _optimizer_cost_based_transformation string                           OFF
    optimizer_dynamic_sampling           integer                          2
    optimizer_features_enable            string                           10.2.0.4
    optimizer_index_caching              integer                          95
    optimizer_index_cost_adj             integer                          10
    optimizer_mode                       string                           CHOOSE
    optimizer_secure_view_merging        boolean                          TRUE
    db_file_multiblock_read_count        integer                          32
    db_block_size                        integer                          8192
    cursor_sharing                       string                           FORCE
    SNAME                PNAME                     PVAL1 PVAL2
    SYSSTATS_INFO        STATUS                          COMPLETED
    SYSSTATS_INFO        DSTART                          04-04-2008 07:02
    SYSSTATS_INFO        DSTOP                           04-04-2008 07:02
    SYSSTATS_INFO        FLAGS                         1
    SYSSTATS_MAIN        CPUSPEEDNW            646.57331
    SYSSTATS_MAIN        IOSEEKTIM                    10
    SYSSTATS_MAIN        IOTFRSPEED                 4096
    SYSSTATS_MAIN        SREADTIM
    SYSSTATS_MAIN        MREADTIM
    SYSSTATS_MAIN        CPUSPEED
    SYSSTATS_MAIN        MBRC
    SYSSTATS_MAIN        MAXTHR
    SYSSTATS_MAIN        SLAVETHR
    SQL> SELECT st.*
      2    FROM t_senttsk st INNER JOIN (WITH t_mrgdusr AS (SELECT DISTINCT usr_id
      3                                                       FROM t_usr
      4                                                      WHERE NVL(usr_mrgemstr, usr_id) = 10000002                    /* i_payer_id */
      5                                                                                                )
      6                                  SELECT t_senttsk.setk_id
      7                                    FROM t_senttsk INNER JOIN t_mrgdusr
      8                                             ON t_senttsk.setk_affn_memb = t_mrgdusr.usr_id
      9                                  UNION
    10                                  SELECT t_senttsk.setk_id
    11                                    FROM t_senttsk INNER JOIN t_mrgdusr
    12                                             ON t_senttsk.setk_ownr = t_mrgdusr.usr_id) t_affil
    13             ON st.setk_id = t_affil.setk_id;
    no rows selected
    Elapsed: 00:13:14.54
    Execution Plan
    Plan hash value: 1241660758
    | Id  | Operation                         | Name                        | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                  |                             |   169K|    64M|  1403   (3)| 00:00:17 |
    |   1 |  NESTED LOOPS                     |                             |   169K|    64M|  1403   (3)| 00:00:17 |
    |   2 |   TABLE ACCESS FULL               | T_SENTTSK                   |   136K|    51M|  1400   (3)| 00:00:17 |
    |   3 |   VIEW                            |                             |     1 |     6 |     1   (0)| 00:00:01 |
    |   4 |    TEMP TABLE TRANSFORMATION      |                             |       |       |            |          |
    |   5 |     LOAD AS SELECT                |                             |       |       |            |          |
    |   6 |      TABLE ACCESS BY INDEX ROWID  | T_USR                       |     1 |     8 |     1   (0)| 00:00:01 |
    |*  7 |       INDEX RANGE SCAN            | IX_NVL_USR_MRGEMSTR_USR_ID  |     1 |       |     1   (0)| 00:00:01 |
    |   8 |     SORT UNIQUE                   |                             |       |       |            |          |
    |   9 |      UNION-ALL PARTITION          |                             |       |       |            |          |
    |  10 |       NESTED LOOPS                |                             |     1 |    25 |     3   (0)| 00:00:01 |
    |  11 |        TABLE ACCESS BY INDEX ROWID| T_SENTTSK                   |     1 |    12 |     1   (0)| 00:00:01 |
    |* 12 |         INDEX UNIQUE SCAN         | PK_T_SENTTSK                |     1 |       |     1   (0)| 00:00:01 |
    |* 13 |        VIEW                       |                             |     1 |    13 |     2   (0)| 00:00:01 |
    |  14 |         TABLE ACCESS FULL         | SYS_TEMP_0FD9D6608_399116CE |     1 |     6 |     2   (0)| 00:00:01 |
    |  15 |       NESTED LOOPS                |                             |     1 |    22 |     3   (0)| 00:00:01 |
    |* 16 |        TABLE ACCESS BY INDEX ROWID| T_SENTTSK                   |     1 |     9 |     1   (0)| 00:00:01 |
    |* 17 |         INDEX UNIQUE SCAN         | PK_T_SENTTSK                |     1 |       |     1   (0)| 00:00:01 |
    |* 18 |        VIEW                       |                             |     1 |    13 |     2   (0)| 00:00:01 |
    |  19 |         TABLE ACCESS FULL         | SYS_TEMP_0FD9D6608_399116CE |     1 |     6 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       7 - access(NVL("USR_MRGEMSTR","USR_ID")=10000002)
      12 - access("T_SENTTSK"."SETK_ID"="ST"."SETK_ID")
      13 - filter("T_SENTTSK"."SETK_AFFN_MEMB"="T_MRGDUSR"."USR_ID")
      16 - filter("T_SENTTSK"."SETK_OWNR" IS NOT NULL)
      17 - access("T_SENTTSK"."SETK_ID"="ST"."SETK_ID")
      18 - filter("T_SENTTSK"."SETK_OWNR"="T_MRGDUSR"."USR_ID")
    Statistics
            349  recursive calls
         275041  db block gets
        1239881  consistent gets
             26  physical reads
       52730252  redo size
           3312  bytes sent via SQL*Net to client
            240  bytes received via SQL*Net from client
              1  SQL*Net roundtrips to/from client
         136835  sorts (memory)
              0  sorts (disk)
              0  rows processed
    SQL> SELECT /*+ gather_plan_statistics */ st.*
      2    FROM t_senttsk st INNER JOIN (WITH t_mrgdusr AS (SELECT DISTINCT usr_id
      3                                                       FROM t_usr
      4                                                      WHERE NVL(usr_mrgemstr, usr_id) = 10000002                    /* i_payer_id */
      5                                                                                                )
      6                                  SELECT t_senttsk.setk_id
      7                                    FROM t_senttsk INNER JOIN t_mrgdusr
      8                                             ON t_senttsk.setk_affn_memb = t_mrgdusr.usr_id
      9                                  UNION
    10                                  SELECT t_senttsk.setk_id
    11                                    FROM t_senttsk INNER JOIN t_mrgdusr
    12                                             ON t_senttsk.setk_ownr = t_mrgdusr.usr_id) t_affil
    13             ON st.setk_id = t_affil.setk_id;
    no rows selected
    Elapsed: 00:09:15.90
    SQL>
    SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
    PLAN_TABLE_OUTPUT
    SQL_ID  2rc9d2c83a7ak, child number 0
    SELECT /*+ gather_plan_statistics */ st.*   FROM t_senttsk st INNER JOIN (WITH t_mrgdusr AS (SELECT DISTINCT usr_id
                               FROM t_usr                                                     WHERE NVL(usr_mrgemstr, usr_id) = :"SYS_B_0"
                /* i_payer_id */                                                                                               )
                   SELECT t_senttsk.setk_id                                   FROM t_senttsk INNER JOIN t_mrgdusr
               ON t_senttsk.setk_affn_memb = t_mrgdusr.usr_id                                 UNION                                 SELECT
    t_senttsk.setk_id                                   FROM t_senttsk INNER JOIN t_mrgdusr                                            ON
    t_senttsk.setk_ownr = t_mrgdusr.usr_id) t_affil            ON st.setk_id = t_affil.setk_id
    Plan hash value: 1065206678
    | Id  | Operation                         | Name                        | Starts | E-Rows | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |
    |   1 |  NESTED LOOPS                     |                             |      1 |    169K|      0 |00:09:02.47 |    1514K|       |       |          |
    |   2 |   TABLE ACCESS FULL               | T_SENTTSK                   |      1 |    136K|    136K|00:00:01.64 |    7062 |       |       |          |
    |   3 |   VIEW                            |                             |    136K|      1 |      0 |00:09:00.54 |    1507K|       |       |          |
    |   4 |    TEMP TABLE TRANSFORMATION      |                             |    136K|        |      0 |00:09:00.12 |    1507K|       |       |          |
    |   5 |     LOAD AS SELECT                |                             |    136K|        |      0 |00:08:24.31 |     548K|  1024 |  1024 |          |
    |   6 |      TABLE ACCESS BY INDEX ROWID  | T_USR                       |    136K|      1 |      0 |00:00:06.12 |     410K|       |       |          |
    |*  7 |       INDEX RANGE SCAN            | IX_NVL_USR_MRGEMSTR_USR_ID  |    136K|      1 |      0 |00:00:05.41 |     410K|       |       |          |
    |   8 |     SORT UNIQUE                   |                             |    136K|        |      0 |00:00:19.10 |     822K|  1024 |  1024 |          |
    |   9 |      UNION-ALL PARTITION          |                             |    136K|        |      0 |00:00:17.40 |     822K|       |       |          |
    |  10 |       NESTED LOOPS                |                             |    136K|      1 |      0 |00:00:08.02 |     411K|       |       |          |
    |  11 |        TABLE ACCESS BY INDEX ROWID| T_SENTTSK                   |    136K|      1 |    136K|00:00:06.36 |     411K|       |       |          |
    |* 12 |         INDEX UNIQUE SCAN         | PK_T_SENTTSK                |    136K|      1 |    136K|00:00:03.68 |     273K|       |       |          |
    |* 13 |        VIEW                       |                             |    136K|      1 |      0 |00:00:01.03 |       0 |       |       |          |
    |  14 |         TABLE ACCESS FULL         | SYS_TEMP_0FD9D6609_399116CE |    136K|      1 |      0 |00:00:00.67 |       0 |       |       |          |
    |  15 |       NESTED LOOPS                |                             |    136K|      1 |      0 |00:00:06.54 |     411K|       |       |          |
    |* 16 |        TABLE ACCESS BY INDEX ROWID| T_SENTTSK                   |    136K|      1 |  34256 |00:00:05.87 |     411K|       |       |          |
    |* 17 |         INDEX UNIQUE SCAN         | PK_T_SENTTSK                |    136K|      1 |    136K|00:00:03.46 |     273K|       |       |          |
    |* 18 |        VIEW                       |                             |  34256 |      1 |      0 |00:00:00.25 |       0 |       |       |          |
    |  19 |         TABLE ACCESS FULL         | SYS_TEMP_0FD9D6609_399116CE |  34256 |      1 |      0 |00:00:00.16 |       0 |       |       |          |
    Predicate Information (identified by operation id):
       7 - access("T_USR"."SYS_NC00127$"=:SYS_B_0)
      12 - access("T_SENTTSK"."SETK_ID"="ST"."SETK_ID")
      13 - filter("T_SENTTSK"."SETK_AFFN_MEMB"="T_MRGDUSR"."USR_ID")
      16 - filter("T_SENTTSK"."SETK_OWNR" IS NOT NULL)
      17 - access("T_SENTTSK"."SETK_ID"="ST"."SETK_ID")
      18 - filter("T_SENTTSK"."SETK_OWNR"="T_MRGDUSR"."USR_ID")
    hoek wrote:Does rewriting 'the heart of the issue' into like below make any difference?
    select a.*
    from   foo a
    where  exists ( select null
    from   bar b
    where  a.foo_pk_id = b.foo_pk_id
    and    b.some_col = :bind_var
    The UNION in the subquery seems to make that difficult.

  • Posiible to limit query time for any one query

    Hi,
    Using 11.2.0.3
    We have a third-party web-based reporting tool where sql queries are initiated on the database- sometimes the user kills the browser session and query still runs on the database.
    Is it possible ata dtabase level to set max time any one query can run e.g. no query over n hours. This would help kill such queries.
    Also is it possible to cap individual queries to say one query can never use more than n% of cpu, ram available?
    Thanks

    user5716448 wrote:
    Hi,
    Using 11.2.0.3
    We have a third-party web-based reporting tool where sql queries are initiated on the database- sometimes the user kills the browser session and query still runs on the database.
    Is it possible ata dtabase level to set max time any one query can run e.g. no query over n hours. This would help kill such queries.
    Also is it possible to cap individual queries to say one query can never use more than n% of cpu, ram available?
    ThanksIf you have Enterprise Edition licences, this is straightforward with the Resource Manager: set a threshold for MAX_EST_EXEC_TIME and all queries that might exceed this will be blocked. You also have CPU limits available.
    John Watson
    Oracle Certified Master DBA
    http://skillbuilders.com

  • Sequencing multiple versions of the VMWare vSphere client (and reducing the size of the final sequence)

    Application Name:  vSphere client
    Application Version:  4.1, 5.0, and 5.5 (all in one package)
    Company Name:  VMWare
    Sequencer Version:  5.0 SP1 or SP2
    App-V Client Version Tested On:  5.0, 5.0 SP1, 5.0 SP2
    Operating System Sequenced On:  Windows 7 (64bit)
    Pre-requisites:  Orca
    Client Operating Systems Successfully Deployed To:  Windows 7 (64bit), Windows Server 2008 (64bit)
    *Posted by non-Microsoft Employee:  Cody Lambert (a Fortune 100 company)
    If Posted by Microsoft Employee, the Corresponding KB Article Reference: 
    N/A
    Steps to Prepare and Sequence the Application:
    Phase 1:  Prepare vSphere install to be used in your sequence (to be performed prior to sequencing)
    Clear %TEMP% directory on machine you are using to prepare the install
    Create a folder that will be referred to as "vSphereInstDir"
    that install files are copied to
    Download the vSphere 5.5 client from your vSphere management server
    Run the installer for the vSphere Client
    Once at the Language Selection portion of the installer,
    using windows explorer browse to the %temp% directory and copy the files that were just created when the vSphere installer extracted to a directory (name it vSphereInstDir)
    Kill the installer
    Find VMware-viclient.exe in the files you just copied
    and run it
    Once at the "Welcome to the installation
    wizard" stage of the installer, using windows explorer browse to the %temp% directory and copy the files that were just created into the vSphereInstDir
    Kill the installer
    Find the VMware vSphere Client 5.5.msi in the vSphereInstDir,
    in the second set of files you copied over
    Using Orca, open the VMware vSphere Client 5.5.msi
    Drop the following rows from the msi (some of the rows may have additional text at the end of the names) (InstallExecuteSequence/VM_InstallHcmon,
    InstallExecuteSequence/VM_InstallHcmon_SetData,
    InstallExecuteSequence/VM_InstallUSB,
    InstallExecuteSequence/VM_InstallUSB_SetData,
    InstallExecuteSequence/VM_InstallUSBArbritrator,
    InstallExecuteSequence/VM_InstallUSBArbritratorSetData,
    InstallExecuteSequence/VM_StartUSBArbSvc) 
    Save the VMware vSphere 5.5.msi in place
    Copy the vSphereInstDir to a network location that
    can be used during sequencing on your Sequencer
    Phase 2:  Sequence the vSphere Client
    Pre-requisites:  All of the latest available VC++ redist (x64 and x86) are installed on the Sequencer VM
    Copy vSphereInstDir to your temporary install directory on your Sequencer (mine is C:\temp)
    Start up the Sequencer
    Click Create a New Virtual Application Package
    Click Next with Create Package (default) selected
    Click Next on the Prepare Computer screen, taking
    note of any findings
    Click Next with Standard Application (default) selected
    Choose Perform a custom installation, then click Next
    Input the Virtual Application name (vSphere Client
    5.5 for example)
    Enter the Primary Virtual Application Directory (C:\vSphere55
    for example) and click Next
    Using Windows Explorer find the Visual J# install (vjredist64.exe) in the vSphereInstDir you copied over.  Install using defaults
    Using Windows Explorer, find and install the vSphere client using the VMware vSphere Client 5.0.msi located in the vSphereInstDir you copied over. 
    Change the installation directory to use the Primary Virtual Application Directory you configured above (C:\vSphere55 for example).  Install using
    defaults
    While the sequencer is still monitoring changes connect to the 4.1 environment to get the files needed.  To do this, launch the vSphere client and connect
    to your 4.1 environment.  When prompted, choose RUN to install the files needed for the 4.1 environment.
    While the sequencer is still monitoring changes connect to the 5.0 environment to get the files needed.  To do this, launch the vSphere client and
    connect to your 5.0 environment.  When prompted, choose RUN to install the files needed for the 5.0 environment.
    With the sequencer still monitoring changes, after the additional environments have been installed, delete all of the language folders from the install locations
    that are not required.  You will find that there are language folders in each of the different modules that are installed.  Make sure look in every folder.  This will free up approximately 300mb from the package.
    When done, check the box to finish the sequence and continue cleaning up the sequenced application.
    Known Issues/Limitations: 
    Functions that require the USB Arbritration Service will not work
    Approximate Sequencing Time: 
    20 minutes
    Descriptive Tags: 
    App-V, 5.0, VMWare, vSphere, Recipe, Guidance
    Credit Due:  Thanks to Rorymon and Aaron Parker for accurate information that allowed for me to put together this recipe.

    Can you double check the that the following were removed from the MSI:
    InstallExecuteSequence/VM_InstallHcmon
    InstallExecuteSequence/VM_InstallHcmon_SetData
    InstallExecuteSequence/VM_InstallUSB
    InstallExecuteSequence/VM_InstallUSB_SetData
    InstallExecuteSequence/VM_InstallUSBArbritrator
    InstallExecuteSequence/VM_InstallUSBArbritratorSetData
    InstallExecuteSequence/VM_StartUSBArbSvc

  • How do I increase the size of the icons on the Bookmarks Toolbar in Waterfox 16

    One would assume this would be an option when customizing the toolbars. When I was doing FF betas, i reported this and later suggested it.
    (the previous similar question was closed in 2011 and the answer doesnt apply)

    I assume that the same CSS code in userChrome.css that works in Firefox should also work with Waterfox.
    Add code to the userChrome.css file below the default @namespace line.
    *http://kb.mozillazine.org/userChrome.css
    <pre><nowiki>@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* only needed once */
    #personal-bookmarks .bookmark-item > .toolbarbutton-icon { height:24px!important; width:24px!important;}</nowiki></pre>

Maybe you are looking for

  • How to get all Conditions in Advanced Search

    Hi All, I'm implementing the AdvancedSearch using Query bean. I have defined the Criteria row with one Item of Varchar2 Datatype. On Advance Search the poplist shows only two conditions (Lookup type=ICX_CONDITIONS) of "is" and "is not". How to get th

  • Best practice migration 10.4.11 G4 PPC to Intel server

    We are ready to upgrade our aging server to a new Intel system. I am wondering the easiest approach. The current server is not running the Universal 10.4. I don't believe there is any viable option that doesn't require lots of hands on rebuilding to

  • Photoshop CC "file-open-desktop" problems

    Why do I get a list showing every folder and every image file therein (a huge list) when I really want just a list of folders? Can't find a preference to change this. Also, when I do scroll to the desired file and image file, I can't click-select tha

  • LiveCycle in the UK

    I am an IT Trainer living and working in the UK with some experience of teaching the LiveCycle Designer, Forms and Workflow courses. I had a few courses to teach in the 2nd quarter of 2006 but nothing since. I have been given my work through Adobe. D

  • Can't connect to windows sbs 2003 using Leopard...

    Hey there... I'm one of 3 Mac users at our office. We use Windows Small Business Server 2003. Since upgrading to Leopard, I can no longer access the network shared folders. Didn't even think about this when upgrading. Our IT guy is strictly a Windows