CBO does not choose the right execution plan

Database: Oracle 9.2.0.6 EA
OS: Solaris 9

I'm trying to settle a query that is generated through Siebel Analytics. I see a behavior which is confusing to me but I hope, would be 'basic' for someone like JPL.

The query is based on a total of 7 tables. If I comment on the 2 dimension tables, the query takes the right index finger on the fact table. However, at the point where I have to add another table to the query, the plan goes awry.

The query with 5 tables is as below:
select count(distinct decode( T30256.HEADER_FLG , 'N' , T30256.ROW_WID ) ) as c1,
T352305.DAY_DT as c2,
case  when T44643.PRODUCT_CLASS_NAME = 'MobileSubscription' then T40081.ATTR15_CHAR_VAL else 'Unspecified' end  as c3,
T352305.ROW_WID as c5
from 
               W_PRODUCT_D T30955,
               W_PRDATTRNM_D T44643,                          
               W_DAY_D T352305,                  
               W_ORDERITEM_F T30256,               
               W_PRDATTR_D T40081                          
where  ( T30955.ROW_WID = T44643.ROW_WID 
and T30256.LAST_UPD_DT_WID = T352305.ROW_WID 
and T30256.PROD_ATTRIB_WID = T40081.ROW_WID  
and T30256.PROD_WID = T30955.ROW_WID 
and T30955.PROD_NAME = 'Mobile Subscription' 
and (case  when T44643.PRODUCT_CLASS_NAME = 'MobileSubscription' then T40081.ATTR15_CHAR_VAL else 'Unspecified' end  in ('BT150BB-18M', 'BT250BB-18M', 'BT50BB-18M', 'BT600BB-18M')) 
and T352305.DAY_DT between TO_DATE('2008-09-27' , 'YYYY-MM-DD') - 7 and TO_DATE('2008-09-27' , 'YYYY-MM-DD') - 1 
) 
group by 
T352305.ROW_WID, T352305.DAY_DT, 
case  when T44643.PRODUCT_CLASS_NAME = 'MobileSubscription' then T40081.ATTR15_CHAR_VAL else 'Unspecified' end 
;
And the implementation plan is as below:
----------------------------------------------------------------------------------------------
| Id  | Operation                        |  Name                | Rows  | Bytes | Cost (%CPU)|
----------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                 |                      |   269 | 25824 | 18660   (3)|
|   1 |  SORT GROUP BY                   |                      |   269 | 25824 | 18660   (3)|
|   2 |   NESTED LOOPS                   |                      |   269 | 25824 | 18658   (3)|
|   3 |    NESTED LOOPS                  |                      |  6826 |   579K|  4734   (3)|
|   4 |     MERGE JOIN CARTESIAN         |                      |     8 |   544 |     6  (17)|
|   5 |      NESTED LOOPS                |                      |     1 |    54 |     4  (25)|
|   6 |       TABLE ACCESS BY INDEX ROWID| W_PRODUCT_D          |     1 |    37 |     3  (34)|
|*  7 |        INDEX RANGE SCAN          | W_PRODUCT_D_M2       |     1 |       |     2  (50)|
|   8 |       TABLE ACCESS BY INDEX ROWID| W_PRDATTRNM_D        |     1 |    17 |     2  (50)|
|*  9 |        INDEX UNIQUE SCAN         | W_PRDATTRNM_D_P1     |     1 |       |            |
|  10 |      BUFFER SORT                 |                      |     8 |   112 |     4   (0)|
|  11 |       TABLE ACCESS BY INDEX ROWID| W_DAY_D              |     8 |   112 |     3  (34)|
|* 12 |        INDEX RANGE SCAN          | W_DAY_D_M39          |     8 |       |     2  (50)|
|  13 |     TABLE ACCESS BY INDEX ROWID  | W_ORDERITEM_F        |   849 | 16131 |   592   (3)|
|* 14 |      INDEX RANGE SCAN            | W_ORDERITEM_F_INDX9  |   852 |       |     4  (25)|
|* 15 |    INDEX RANGE SCAN              | W_PRDATTR_D_M29_T1   |     1 |     9 |     3  (34)|
----------------------------------------------------------------------------------------------
Note how the dimension tables W_PRODUCT_D & W_DAY_D are connected by a Cartesian join before joining the fact W_ORDERITEM_F table using the composite index 'W_ORDERITEM_F_INDX9 '. This index is composed of LAST_UPD_DT_WID, PROD_WID and ACTION_TYPE_WID, which are foreign keys to the dimension tables.

Now, if I add several tables to the query:
select count(distinct decode( T30256.HEADER_FLG , 'N' , T30256.ROW_WID ) ) as c1,
              T352305.DAY_DT as c2,
               case  when T44643.PRODUCT_CLASS_NAME = 'MobileSubscription' then T40081.ATTR15_CHAR_VAL else 'Unspecified' end  as c3,
               T30371.X_BT_DLR_GROUP as c4,
               T352305.ROW_WID as c5
          from                W_PRODUCT_D T30955,
               W_PRDATTRNM_D T44643,                          
               W_DAY_D T352305,                  
               W_ORDERITEM_F T30256,               
               W_ORDER_D T30371,                                             
               W_PRDATTR_D T40081                          
          where  ( T30955.ROW_WID = T44643.ROW_WID 
          and T30256.LAST_UPD_DT_WID = T352305.ROW_WID 
          and T30256.PROD_ATTRIB_WID = T40081.ROW_WID 
          and T30256.PROD_WID = T30955.ROW_WID 
          and T30256.ORDER_WID = T30371.ROW_WID 
          and T30955.PROD_NAME = 'Mobile Subscription' 
          and T30371.STATUS_CD = 'Complete' 
          and T30371.ORDER_TYPE = 'Sales Order'  
          and (case  when T44643.PRODUCT_CLASS_NAME = 'MobileSubscription' then T40081.ATTR15_CHAR_VAL else 'Unspecified' end  in ('BT150BB-18M', 'BT250BB-18M', 'BT50BB-18M', 'BT600BB-18M')) 
          and T352305.DAY_DT between TO_DATE('2008-09-27' , 'YYYY-MM-DD') - 7 and TO_DATE('2008-09-27' , 'YYYY-MM-DD') - 1 
         ) 
          group by T30371.X_BT_DLR_GROUP, T352305.ROW_WID, T352305.DAY_DT, 
          case  when T44643.PRODUCT_CLASS_NAME = 'MobileSubscription' then T40081.ATTR15_CHAR_VAL else 'Unspecified' end;
I added a single table W_ORDER_D to the query and execution plan is:
-----------------------------------------------------------------------------------------------
| Id  | Operation                          |  Name               | Rows  | Bytes | Cost (%CPU)|
-----------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                   |                     |    44 |  6336 | 78695   (3)|
|   1 |  SORT GROUP BY                     |                     |    44 |  6336 | 78695   (3)|
|   2 |   NESTED LOOPS                     |                     |    44 |  6336 | 78694   (3)|
|   3 |    NESTED LOOPS                    |                     |   269 | 27707 | 78145   (3)|
|*  4 |     HASH JOIN                      |                     |  6826 |   626K| 64221   (3)|
|   5 |      TABLE ACCESS BY INDEX ROWID   | W_DAY_D             |     8 |   112 |     4  (25)|
|*  6 |       INDEX RANGE SCAN             | W_DAY_D_M39         |     1 |       |     3  (34)|
|   7 |      TABLE ACCESS BY INDEX ROWID   | W_ORDERITEM_F       | 86886 |  2206K| 64197   (3)|
|   8 |       NESTED LOOPS                 |                     | 87004 |  6797K| 64200   (3)|
|   9 |        NESTED LOOPS                |                     |     1 |    54 |     4  (25)|
|  10 |         TABLE ACCESS BY INDEX ROWID| W_PRODUCT_D         |     1 |    37 |     3  (34)|
|* 11 |          INDEX RANGE SCAN          | W_PRODUCT_D_M2      |     1 |       |     2  (50)|
|  12 |         TABLE ACCESS BY INDEX ROWID| W_PRDATTRNM_D       |     1 |    17 |     2  (50)|
|* 13 |          INDEX UNIQUE SCAN         | W_PRDATTRNM_D_P1    |     1 |       |            |
|* 14 |        INDEX RANGE SCAN            | W_ORDERITEM_F_N6    | 86886 |       |   212  (18)|
|* 15 |     INDEX RANGE SCAN               | W_PRDATTR_D_M29_T1  |     1 |     9 |     3  (34)|
|* 16 |    INDEX RANGE SCAN                | W_ORDER_D_N6        |     1 |    41 |     3  (34)|
-----------------------------------------------------------------------------------------------
Now, CBO choose the composite index and the cost has also increased to 78695. But if I just add a / * + SORTED * / referring to the above query, whereas it should join the dimension tables prior to joining the fact table, then the cost falls to 20913. This means that CBO is not choose the plan with the lowest cost. I tried increasing the optimizer_max_permutations 80000, setting session optimizer_dynamic_sampling level 8 (just to see if it works), but without success.

Could you please tell how to overcome this problem?

Thank you very much.

joshic wrote:
Hi Randolph,

The optimizer is set to 'choose', which is the default in 9i. So I guess that CBO uses the "all_rows" mode, because his stats are present.

According to your advice, I tried to adjust optimizer_mode, first_rows_1, first_rows_10, first_rows_100 and all_rows at the session level, but nothing helped.

Another question: since you are obviously having a schema star why don't you use not three separate bitmap indexes on the foreign key columns in the fact table? In this way, you can use a transformation star rather than using a composite index.

You use many OLTP, small, such as transactions that modify your fact table, or is it only loaded by loading in bulk? If you use only loads in bulk index bitmap should be fine.

Kind regards
Randolf

Oracle related blog stuff:
http://Oracle-Randolf.blogspot.com/

SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676 /.
http://sourceforge.NET/projects/SQLT-pp/

Tags: Database

Similar Questions

  • I bought the ability to convert PDF files into word documents. However, when I opened a PDF it does not include the right panel that had been giving me the option to convert. After spending 30 minutes on a cat, I learned that (1) the option is not on the

    I bought the ability to convert PDF files into word documents. However, when I opened a PDF it does not include the right panel that had been giving me the option to convert. After spending 30 minutes on a cat, I've learned that (1) the option is not on the right side panel on Acrobat 9 Pro, (2) it is on the top. What should I do to convert my files?

    Look at the file menu.

  • Windows 8 xcopy /d - does not choose the date of the day, just copy everything

    Hello

    I am running Windows 8 and use the command xcopy to save a number of directories. When I used the /D switch in the past (with no date), it would only copy the files that are newer than the target date of the mod file.

    In Windows 8, it does not. If I use / d with no specific date, it copies just everything. The only way to make it work is to specify the current date, while it works.

    I'm doing something wrong, or is this a bug in xcopy to win 8?

    Hi Chris,

    Your question is better suited for the TechNet. Please post your question in the forum TechNet Script. You can follow the link to your question:

    http://social.technet.Microsoft.com/forums/scriptcenter/en-us/home?Forum=iTCG

    Thank you.

  • Website phone does not display the right width immediately

    We have created a site Office Web and phone.

    Everything works fine, but on a phone, the site is, in the first instance left aligned and too small and that jumps to the right width.

    This occurs on all pages.

    What is the problem?

    This has been resolved. We have created a new master page copied and paste everything from the old master page to the new.

    The problem disappeared. We have had these problems with the master pages before.

  • Hello, I have a question about the new plan to PHOTOGRAPH creative Cloud. Does not include the feature of plan free prosite? and what is the difference with the new Adobe portfolio application?

    Adobe Creative Cloud

    Please check the features

    Lightroom and Photoshop | Plan of cloud of Adobe's creative photography

    http://prodesigntools.com/creative-cloud-photography-plan.html

    Concerning

    Stéphane

  • My bevel and Emboss does not recognize the right choice

    So I found a model online. I imported into PS, I then used the perspective deformation tool to stretch it in place. Now I would like to in bevel and Emboss the holes, however, after the selection, he in bevel and grit the model itself. And it is pixelated. I don't know what is happening.

    Screen Shot 2015-05-16 at 11.46.20 AM.png

    selected holes...

    Screen Shot 2015-05-16 at 11.47.15 AM.png

    See how it's cut the whole Board? I don't know what is happening. I want that the holes to be cut.

    Thanks in advance,

    Tom

    After you make the selection, choose Cmd + J to put this item on its own layer. Then you apply bevel & Emboss. That should give you the result you are after.

  • using nested case statement does not get the right result

    Hello all;

    I have a sample of data similar to below
    create table t3
    ( 
           id varchar2(200),
           qty number(30),
           qty2 number(30)
    ); 
     insert into t3
       (id, qty, qty2)
     values
       ('A', 10, null);
     
      insert into t3
       (id, qty, qty2)
     values
       ('A', 20, null);
       
     insert into t3
       (id, qty, qty2)
     values
       ('B', null, 5);
       
    insert into t3
       (id, qty, qty2)
     values
       ('B', null, 5);
       
     insert into t3
       (id, qty, qty2)
     values
       ('C', null, -5);
       
    insert into t3
       (id, qty, qty2)
     values
       ('C', null, 5);
    
    
     insert into t3
       (id, qty, qty2)
     values
       ('D', -1, -2);
       
    insert into t3
       (id, qty, qty2)
     values
       ('D', 1, 4);
    This is what looks like data
    ID  QTY  QTY2
    A    10
    A    20
    B              5
    B              5
    C             -5
    C              5
    D    1        4
    D   -1       -2
    It is the output that I desired below
    ID    Status 
    A      Fail
    B      Fail
    C      Pass
    D      Fail
    A is a failure because the sum of the 2 has the value zero, where the summation of the qty was used to determine the State and because the sum of the quantity is not equal to zero, then, it is a failure
    D is a failure because even if the sum of the Qty 1 equals zero, we must make use of summation of the qty 2 instead because he is not null to determine the status and the summation of the qty is 2, where a failure
    etc.

    I tried write something but can not make it work
    select case when sum(v.qty) is not null
                and sum(v.qty) = 0 then 'Pass'
                when sum(v.qty) is not null
                and sum(v.qty) != 0 then 'Fail'
           else
             case when sum(v.qty2) is not null
               and sum(v.qty2) = 0 then 'Pass'
               else
                when sum(v.qty2) is not null 
                  and sum(v.qty2) != 0 then 'Fail'
                  end as status
              end as status
    
    
     from t3 v;
    any help is appreciated. Thank you.

    Try this,

    SELECT ID,
           CASE WHEN NVL(SUM (qty2),1) !=0 THEN 'fail'
                WHEN NVL(SUM (qty),0) != 0 THEN 'fail'
                ELSE 'pass'
           END
      FROM t3
    GROUP BY ID
    
    OUTPUT
    -------------
    
    ID RESULT
    -- ------
    A  fail
    B  fail
    C  pass
    D  fail
    Z  fail
    

    G.

  • Photoshop CS5.5 does not show the right amount of RAM

    I have a PC with 3.25 MB of memory.  I recently bought the CS5.5 creative Suite.  I change my preference when I noticed on the performance under memory usage tab, it says:

    Available RAM 1569
    Ideal range: 863-1129

    I use Photoshop: 941 MB

    Anyone know why Photoshop is only see 1/2 of my memory?

    You run the 32-bit version of Photoshop, which can not use all the system RAM.

    You use also a 32 bit OS, then you will not be able to run the 64-bit version.

    In 32 bits, Photoshop can use up to 2 GB of address space.

    And some of this space is used by the binary files, plugins, presets, etc.

  • 16 GB Cruzer does not show the right amount of storage

    I bought a SansDisk Cruzer 16 GB model: SDCZ60 - 16G

    I used to perform a restore of the system for my Chromebook and after that the installation went through the player will show only 1.96 1.96 MB of available space.

    I tried to format it all over the place. I was wondering if anyone has experienced this problem or if there is the software at the factory reset.

    No matter what information you have I would be very happy.

    Okay, figured it out!

    For later use, you must have the installation of chrome os image recovery program:

    • you run it
    • Select another option
    • multimedia format

    Hope this helps some other poor sap

    Source: http://www.samsung.com/us/support/howtoguide/N0000442/6833/45819/N/2/M/

  • MY DASHBOARD LINK DOES NOT IN THE RIGHT PLACE

    Hello developers,
    So, I created a dashboard link on my record of sale using the transaction as link number. When the user clicks on a particular transact # they are supposed to go to the screen next where they will see more details about this transaction in particular. NOW, in my tests when I click transact number it doesn't direct me to this specific transaction instead need me the report detailed, but with any other transact #s. I'm sure that I've created the exact report when I created the link. Any idea what I could have done wrong on that?


    Help, please

    You must have set the column in number of transactions in the target report "is invited", as already mentioned.

    There must be something that be overlooked. I take a look at the SQL and make sure "" is bringing"filter in the target report is the same column that is that is clicked on the source report.

    JB

  • LV does not print the barcode fonts

    It's the VI, I created to print a barcode. I set up the type size and police and then sent to the printer. But LV does not print the right font. When I made the same format in WORD and print, print correctly.

    Barcode font, I used is not installed on the local PC, but it is available in the printer driver. I guess this is the reason why print all fines. WHY CAN'T LV?

    You can simply use the TCP protocol to establish a connection to the printer on port 9100. The printer is set up to automatically close the connections that are inactive after 5 minutes. If you send only from time to time the label you must close the connection and reopen it when you send the next label. If you send a relatively steady stream of labels, you can leave the connection open.

  • Quiz - not recognizing the right answers

    Just try to create a quiz using Captivate.

    I thought that I understood, except that it does not recognize the right answers.

    http://www.learners-Guide.co.UK/QuizTest/Captivate/tests/test3/test3/index.html

    I checked the box to tick boxes for Q2 and Q1.

    That I may have hurt or spleen?

    Thank you.

    Donal thanks. Look again I can see what I was going to hurt. I was clicking "Next" rather than "submit" after each question. Thinking about it, I assumed that 'next' lets back you to the questions that you might want to mull over.

  • My shortcuts Office does not, to the left or right click nothing.

    My shortcuts Office does not, to the left or right click nothing.

    My shortcuts Office does not, to the left or right click nothing.

    Suggestions:

    1 rebuild icon cache. Yours could be damaged.

    http://www.SevenForums.com/tutorials/49819-icon-cache-rebuild.html

    2. If this is a recent problem, and if you remember one ate when shortcuts worked ok, do a system restore.
    Choose a date where shortcuts worked as your restore point.
    http://www.howtogeek.com/HOWTO/Windows-Vista/using-Windows-Vista-system-restore/

    3. restore explorer.exe

    Press CTRL + Alt + Delete > Task Manager > processes tab > right click on explorer.exe > click on end process > Applications tab > new task... > in the Open box, type explorer.exe > OK

     
  • its ridiculous... I asked for the plan a month and cloud it recharges on a monthly basis and now when I try to cancel the membership that it does not show the desired option...

    its ridiculous... I asked for the plan a month and cloud it recharges on a monthly basis and now when I try to cancel the membership that it does not show the desired option...

    Cancel your membership creative cloud

    To the link below, click on the still need help? option in the blue box below and choose the option to chat or by phone...
    Make sure that you are logged on the Adobe site, having cookies enabled, clearing your cookie cache.  If he continues to not try to use a different browser.

    https://helpx.Adobe.com/contact.html?step=CCSN_membership-account-payment_cancel-your-memb ership_stillNeedHelp

  • In FF 25 on XP there was a star to the left of the navigation bar to open the bookmarks bar, now he is on the right, but does not open the box - what's up?

    I want this little star back that opens the bookmarks bar. It's just to the left of the field address on XP in FP 25. But Windows 8 in FP 25.0.1 is not there. Instead, there is a star that sometimes appears on the right side of the address bar. But the star on the right does not open the bookmarks bar. It shows only a list of bookmarks and options, which do not include the opening of the sidebar.
    This option has been removed and replaced by Ctrl B?

    Thank you. I don't know what happened, but somewhere in the workplace with classic theme restaurateur, I fell Classic 1.4 of toolbar buttons and found the icon and figured out how to say up there.

Maybe you are looking for

  • Apple Watch will come after restoring iPhone

    I had to restore my iPhone 6 yesterday and has no a pair my Apple Watch him first, now my watch won't come at all for power re-pair it with my phone. Any ideas/suggestions would be appreciated. Thanks in advance.

  • How to exit the shuffle on iTouch?

    Shuffle is all the time and there's no way to turn it off or do it change to repeat the same song over and over again. I could do in my old iPod, but the iTouch doesn't seem to have this menu.

  • Reading of data of VISA

    Hello I am a beginner total with labview and searched but to no avail. I MC who ensures the pumping data from five sensors, each sensor comes out a little higher and a little weak. I created a VI that reads in the data and converts the string to an a

  • program has encountered a problem

    I installed a new program and when I try to start it, a message appears that the program has encountered a problem and needs to close. It has been suggested from the supplier of the program to create a new profile, and then try again. I did and the p

  • Restore Vista o/s to Win 8.1 upgrade. Restore disks will still work?

    My HP G60 came with Vista. It has been upgraded to Windows 8.1 but the audio has become non-functional. Is it necessary for a new driver solve the problem? If not, I think to restore Vista restore disks. Restore disks can still work now that there Wi