10g Optimizer strange behavour

I think the Optimizer has a problem in 10g. (or in my installation)
Consider the following query:
Select field1 from table where keyfield = 'ABC' (this value only occurs 10 times)
This table has 30.000 records. If I put an index on keyfield the query tasks 5 sec. If I remove the index the query takes 1 sec. This is not logical.
This problem only occurs on 10g, the same query takes <1 sec on Oracle 8 or Oracle 9.
I think the Optimizer is having a problem analyzing the index. The analyzing step i think takes a lot of time (maybe 4 sec). Is this possible?
I already removed and added the index, created statistics, also set the optimizing mode to choose; always the same results.
Does anyone has a clue about this problem?

According to what you described you have an index on a column with around 10/30,000 values. When the index is in place the query takes 5 seconds; without the index the query takes 1 second. Sounds like a problem to me.
There are a few more things I would check:
Are you using histograms? They're designed for mixed-cardinality data to allow the CBO to dynamically decide when an index will help or not based on data values. I have seldom seen them used, but they can have an effect on queries when the histogram column value is hard-coded in the WHERE clause (bind variables don't work because histograms are considered before the bind variable value is examined by the optimizer).
Are you analyzing both the table and the index(es)? Are you using DBMS_STATS, which is supposed to be better than the ANALYZE command (I'm personally dubious for no good reason, but our DBA group swears by DBMS_STATS)?
There is a recognized problem with 10g called "bind variable peeking". the situation is that you run the same query twice with different sets of bind variables. The query is optimized for the first execution, but the values of the second execution are such that the query runs (with the first's plan) inefficently. This can be turned off with an undocumented intialization paramter.
I agree that the execution plans might be helpful to figure out what is going on.

Similar Messages

  • Pl/sql boolean expression short circuit behavior and the 10g optimizer

    Oracle documents that a PL/SQL IF condition such as
    IF p OR q
    will always short circuit if p is TRUE. The documents confirm that this is also true for CASE and for COALESCE and DECODE (although DECODE is not available in PL/SQL).
    Charles Wetherell, in his paper "Freedom, Order and PL/SQL Optimization," (available on OTN) says that "For most operators, operands may be evaluated in any order. There are some operators (OR, AND, IN, CASE, and so on) which enforce some order of evaluation on their operands."
    My questions:
    (1) In his list of "operators that enforce some order of evaluation," what does "and so on" include?
    (2) Is short circuit evaluation ALWAYS used with Boolean expressions in PL/SQL, even when they the expression is outside one of these statements? For example:
    boolvariable := p OR q;
    Or:
    CALL foo(p or q);

    This is a very interesting paper. To attempt to answer your questions:-
    1) I suppose BETWEEN would be included in the "and so on" list.
    2) I've tried to come up with a reasonably simple means of investigating this below. What I'm attempting to do it to run a series of evaluations and record everything that is evaluated. To do this, I have a simple package (PKG) that has two functions (F1 and F2), both returning a constant (0 and 1, respectively). These functions are "naughty" in that they write the fact they have been called to a table (T). First the simple code.
    SQL> CREATE TABLE t( c1 VARCHAR2(30), c2 VARCHAR2(30) );
    Table created.
    SQL>
    SQL> CREATE OR REPLACE PACKAGE pkg AS
      2     FUNCTION f1( p IN VARCHAR2 ) RETURN NUMBER;
      3     FUNCTION f2( p IN VARCHAR2 ) RETURN NUMBER;
      4  END pkg;
      5  /
    Package created.
    SQL>
    SQL> CREATE OR REPLACE PACKAGE BODY pkg AS
      2 
      3     PROCEDURE ins( p1 IN VARCHAR2, p2 IN VARCHAR2 ) IS
      4        PRAGMA autonomous_transaction;
      5     BEGIN
      6        INSERT INTO t( c1, c2 ) VALUES( p1, p2 );
      7        COMMIT;
      8     END ins;
      9 
    10     FUNCTION f1( p IN VARCHAR2 ) RETURN NUMBER IS
    11     BEGIN
    12        ins( p, 'F1' );
    13        RETURN 0;
    14     END f1;
    15 
    16     FUNCTION f2( p IN VARCHAR2 ) RETURN NUMBER IS
    17     BEGIN
    18        ins( p, 'F2' );
    19        RETURN 1;
    20     END f2;
    21 
    22  END pkg;
    23  /
    Package body created.Now to demonstrate how CASE and COALESCE short-circuits further evaluations whereas NVL doesn't, we can run a simple SQL statement and look at what we recorded in T after.
    SQL> SELECT SUM(
      2           CASE
      3              WHEN pkg.f1('CASE') = 0
      4              OR   pkg.f2('CASE') = 1
      5              THEN 0
      6              ELSE 1
      7           END
      8           ) AS just_a_number_1
      9  ,      SUM(
    10           NVL( pkg.f1('NVL'), pkg.f2('NVL') )
    11           ) AS just_a_number_2
    12  ,      SUM(
    13           COALESCE(
    14             pkg.f1('COALESCE'),
    15             pkg.f2('COALESCE'))
    16           ) AS just_a_number_3
    17  FROM    user_objects;
    JUST_A_NUMBER_1 JUST_A_NUMBER_2 JUST_A_NUMBER_3
                  0               0               0
    SQL>
    SQL> SELECT c1, c2, count(*)
      2  FROM   t
      3  GROUP  BY
      4         c1, c2;
    C1                             C2                               COUNT(*)
    NVL                            F1                                     41
    NVL                            F2                                     41
    CASE                           F1                                     41
    COALESCE                       F1                                     41We can see that NVL executes both functions even though the first parameter (F1) is never NULL. To see what happens in PL/SQL, I set up the following procedure. In 100 iterations of a loop, this will test both of your queries ( 1) IF ..OR.. and 2) bool := (... OR ...) ).
    SQL> CREATE OR REPLACE PROCEDURE bool_order ( rc OUT SYS_REFCURSOR ) AS
      2 
      3     PROCEDURE take_a_bool( b IN BOOLEAN ) IS
      4     BEGIN
      5        NULL;
      6     END take_a_bool;
      7 
      8  BEGIN
      9 
    10     FOR i IN 1 .. 100 LOOP
    11 
    12        IF pkg.f1('ANON_LOOP') = 0
    13        OR pkg.f2('ANON_LOOP') = 1
    14        THEN
    15           take_a_bool(
    16              pkg.f1('TAKE_A_BOOL') = 0 OR pkg.f2('TAKE_A_BOOL') = 1
    17              );
    18        END IF;
    19 
    20     END LOOP;
    21 
    22     OPEN rc FOR SELECT c1, c2, COUNT(*) AS c3
    23                 FROM   t
    24                 GROUP  BY
    25                        c1, c2;
    26 
    27  END bool_order;
    28  /
    Procedure created.Now to test it...
    SQL> TRUNCATE TABLE t;
    Table truncated.
    SQL>
    SQL> var rc refcursor;
    SQL> set autoprint on
    SQL>
    SQL> exec bool_order(:rc);
    PL/SQL procedure successfully completed.
    C1                             C2                                     C3
    ANON_LOOP                      F1                                    100
    TAKE_A_BOOL                    F1                                    100
    SQL> ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL=0;
    Session altered.
    SQL> exec bool_order(:rc);
    PL/SQL procedure successfully completed.
    C1                             C2                                     C3
    ANON_LOOP                      F1                                    200
    TAKE_A_BOOL                    F1                                    200The above shows that the short-circuiting occurs as documented, under the maximum and minimum optimisation levels ( 10g-specific ). The F2 function is never called. What we have NOT seen, however, is PL/SQL exploiting the freedom to re-order these expressions, presumably because on such a simple example, there is no clear benefit to doing so. And I can verify that switching the order of the calls to F1 and F2 around yields the results in favour of F2 as expected.
    Regards
    Adrian

  • About 10g optimizer

    Hi All,
         I am wondering is any one out there has the same problem with me. I have one same schema on both 9i and 10g. The sql statement runs fine with 9i instance but not with 10g. Especially for those sql statement that has sub query in where clause. What I found out from 10g explain plan is that optimizer create a view for this sub query and it is the most killing part. Any suggestion or comments are welcome.

    Hi,
    there are three points you should try:
    1.) Did you gather system statistics? 9i does not use them if there are not present, but 10g uses default values. But gathering system stats does not invalidate the plan in the shared pool. You will have to execute
    alter system flush shared_poolor simply do some DDL to one of the objects used in your table. If a table is eg. defined with noparallel simply execute
    alter table xy noparallelThis will not change the table but every statement using this table will be hard parsed again.
    Now gather system statistics using:
    begin
    dbms_stats.gather_system_stats('start');
    end;You should do this when you db is under normal workload. After a couple of time(hours) stop it:
    dbms_stats.gather_system_stats('stop');2. Are you able to rewrite the sqls using subquery factoring? Does the plan change?
    3. Try changing the statistics using the dbms_stats.set_table_stats and dbms_stats.set_column_stats procedure. Start with very low or high values.
    Dim

  • Semie addivie measure and strange behavour

    Hi,
    For the first time , I 'm facing a strange behavior with a semi additive  measure.  
    In EXCEL  when I' m crossing it with a product dimension (Declared as Regular type ... no time type),
    the behavour is like we are crossing with a time dimension.
    No SUM on the column ,  but the last non empty value whenever appear. 
     Product Type - Product code        Cummulative Power
    A                                                             16 <--   Problem we don't see No 31  
                             AA1                                  15
                             AA1                                  16
    Total SUM                                                     16    !! no 31
    Does anyone have an idea about this problem ? 
    Thank you very much
    Christophe
    <input id="gt-speech-in" lang="fr" size="1" speech="speech" style="float:left;width:15px;padding:5px 6px;margin:0px;outline:none;border-style:none;background-color:rgba(255,
    255, 255, 0);" tabindex="-1" type="text" x-webkit-grammar="builtin:translate" x-webkit-speech="x-webkit-speech" />
    whenever

    Hi Christophe,
    your question is not clear to me.  From what I understand your facing problem with measure 'Cummulative
    Power' which uses aggregation function  'Last NonEmpty'.
    Don't know whether this will help. In our case 'Last
    NonEmpty' function would be calculating 'Cummulative Power' against 'Product' dimension attributes,
    while the measure value being the value of highest member or last member of time\date dimension. (remember semi additive measures always requires time dimension)
    For example consider the following table.
    Product       
    Date
    Cummulative Power
    A  
    20140101
    10
    B
    20140101
    15
    A  
    20140102
    13
    B
    20140102
    17
    A  
    20140103
    16
    B
    20140103
    11
    Here if 'Last NonEmpty' function is used with Cummulative Power then against each Product we would get the following results in cube.
    Product
    Last NomEmpty(Cummulative Power)
    A
    16
    B
    11
    i.e. the above values are corresponding to the last member of time dimension (20140103) .
    Saurabh Kamath

  • Differences in 9i and 10g optimizer

    Hi,
    If I am migrating from 9i to 10g (10.2), what are the main changes between the optimizers of these 2 versions?
    Where can I find these things in manuals?
    Amy experiances?
    Please share.
    Thanks

    I'm not sure the specifics you are looking for are mentioned in the manuals. Check the 10g New Features manual and check for positings as you are doing.
    One issue we are seeing in 10g is a phenemenon called "bind peeking". This happens when SQL is using bind variables and generates a plan to execute the query. Later the same query text is executed with different values but isn't as efficeint a plan for those values (usually due to index use; sometimes the same situation that histograms are created for) and query performance is not good the second time. There is an undocumented intitalization parameter you can find on metalink (possibly here in OTN) that can turn bind peeking off.

  • Owb 10g Optimize Merge Radio Button

    Having trouble finding documentation on what the "Optimize Merge" radio button does when configuring a mapping and setting up the tables. I am trying to optimize some slow code using an update/insert merge.

    Hi
    Without this switched on the select list for the inserts and updates will be the same, this select statement will include all transformations/expressions before the table operator regardless if they are only done for the update or insert. You could get redundant transformations being performed. So with the optimize merge switched on the code generator will analyze your graph and if possible push any transformation applicable only for insert or update to the appropriate part of the merge statement.
    For diagnosing performance the explain plan and stats packages of the database have been incorporated into mapping which may help you diagnose issues here too.
    Cheers
    David

  • SOFS, CSV available space changes daily, strange behavour

    Hi, I have a a SOFS cluster which is working nicely, around 120 VM, running from 8 CSV volumes.
    but I have noticed that the disk usage goes up and down during the day, one CSV only had 5% free when I checked this morning.
    But overnight it drops back to 20-30% free. if I do a Volume refresh during the Day I can see the available space dropping, 1 or 2 Gig every hour or so.
    now I though this was AVHD snapshots growing but I have checked this, and it not that causing the issue, I also thought it could be DPM, but no backups are running.
    could it be memory of the VM's using extra disk on the VM config ?
    I haven't noticed this behaviour before, and I am pretty interested in whats going on.
    Cheers
    Mark

  • JCombobox Strange Behavour

    I have a JInternalFrame with some JLabels, JTextFields and JComboboxs.
    I have set up all the desirable properties of this components, except from one.
    I want when the jcombobox grab the focus the user have not to click with the mouse at the it (jcombobox)
    in order to appear its choices.
    Instead i want when press the "down arrow" to appear the list and when press the enter (when the lists of
    the choices is appeared) to set this element as the selected.
    Any help is appreciated!!

    You could try something like
    InputMap inputMap = combo.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
    inputMap.put( KeyStroke.getKeyStroke( "DOWN" ), "togglePopup");which should bind down to showing the popup. However, now you've got a problem because down
    would normally move the selection down in the list -- what do you use instead?
    : jay

  • Strange behavour of "People Recognition"

    I've just installed Elements, and was looking forward to test the face recongnition. After install I marked some picures, pressed the "People Recognition" and it analyzed the images. Everything worked out fine.
    Now, a few hours later", when mark some pictures and choose this feature it start the "Analysis". When the progressbar reach 100% it dissapears, and .. well thats it. Nothing more happens.
    Anyone know whats going on, or how this can be fixed?
    Elements Organizer 8.0.0.0
    Core Version: 8.0 (20090905.r.605812)
    Language Version: 8.0 (20090905.r.605812)
    System:
    Operating System Name: XP
    Operating System Version: 5.1 Service Pack 3
    System Architecture: Intel CPU Family:6 Model:15 Stepping:11 with MMX, SSE Integer, SSE FP
    Built-in Memory: 2GB
    Free Memory: 689,8MB

    ... you select some thumbnails and do Find > Find Faces For Tagging.
    The progress bar appears, goes to 100%, and then progress bar
    disappears.  But the Organizer keeps running (it doesn't crash)?
    Yes, this is correct. The same thing happens when I select only one photo. Organizer do not crash.
    I should mention that "Generating thumbnails" is running in the background.

  • Strange behavour

    Hi All,
    I am using EAS and running the following calc script, for example, to clear one period of balance sheet:
    //ESS_LOCALE English_UnitedStates.Latin1@Binary
    Fix(@idescendants("Balance Sheet"), "2011","Forecast 12")
    CLEARBLOCK ALL ;
    ENDFIX
    The script runs successfully, however retrieveing from Excel addin, the data is still there, and I run this couple of times, but data is still not getting clear. This is driving me nuts,
    Any idea?

    The add in and smart view do not cache data. Every retrieval should bring back a new retrieve. Unless you were timed out and you have messages turned off, you should be getting fresh data with every retrieve. The only other possiblilty I can think of is you are clearing Version12 If you are pulling a different version it could have data

  • Upgraded to windows 7 64 strange behavour CS4 Premiere Pro

    Hi,
    I upgraded to windows 7 64 and are using Premiere pro CS4 for the first time on this system.
    I noticed when I click the minus sign (at the top right) to temporarily close the program the little icon shows up at the bottom of the screen like it does with any program on  Windows 7.
    But unfortunately when I try to let it appear on screen again nothing happens. I have to reboot the system to get it working again.
    Also the timeline starts flickering when I play a sequence is this normal?!
    Any one with a solution is very very welcome to reply!
    Thanks David

    More information needed for someone to help
    http://forums.adobe.com/thread/416679
    Some specific information that is needed...
    Brand/Model Computer (or Brand/Model Motherboard if self-built)
    How much system memory you have installed, such as 2Gig or ???
    Operating System version, such as Win7 64bit Pro... or whatevevr
    -including your security settings, such as are YOU the Administrator
    -and have you tried to RIGHT click the program Icon and then select
    -the Run as Administrator option (for Windows, not sure about Mac)
    Your Firewall settings and brand of anti-virus are you running
    Brand/Model graphics card, sush as ATI "xxxx" or nVidia "xxxx"
    -or the brand/model graphics chip if on the motherboard
    -and the exact driver version for the above graphics card/chip
    -and how much video memory you have on your graphics card
    Brand/Model sound card, or sound "chip" name on Motherboard
    -and the exact driver version for the above sound card/chip
    Size(s) and configuration of your hard drive(s)... example below
    -and how much FREE space is available on each drive (in Windows
    -you RIGHT click the drive letter while using Windows Explorer
    -and then select the Properties option to see used/free space)
    Windows Indexing is BAD http://forums.adobe.com/thread/676303
    While in Properties, be sure you have drive indexing set OFF
    -for the drive, and for all directories, to improve performance
    Some/Much of the above are available by going to the Windows
    Control Panel and then the Hardware option (Win7 option name)
    OR Control Panel--System--Hardware Tab--Device Manager for WinXP
    Plus Video-Specific Information http://forums.adobe.com/thread/459220?tstart=0
    And, finally, the EXACT type and size of file that is causing you problems
    -for pictures, that includes the camera used and the pixel dimensions
    Read Bill Hunt on a file type as WRAPPER http://forums.adobe.com/thread/440037?tstart=0
    What is a CODEC... a Primer http://forums.adobe.com/thread/546811?tstart=0
    What CODEC is INSIDE that file? http://forums.adobe.com/thread/440037?tstart=0
    Report back with the codec details of your file, use the programs below
    For PC http://www.headbands.com/gspot/ or http://mediainfo.sourceforge.net/en
    For Mac http://mediainfo.massanti.com/
    Once you know exactly what it is you are editing, report back with that information... and your project setting, and if there is a red line above the video in the timeline, which indicates a mismatch between video and project
    Read Bill Hunt on editing a VOB/MPG file http://forums.adobe.com/thread/464549?tstart=0
    Edit Vob http://premierepro.wikia.com/wiki/FAQ:How_do_I_import_VOB_files_/_edit_a_DVD%3F
    Read Hunt on Using MOD/TOD files http://forums.adobe.com/thread/699990?tstart=0
    Also, Work through all of the steps (ideas) listed at http://forums.adobe.com/thread/459220?tstart=0
    If your problem isn't fixed after you follow all of the steps, report back with ALL OF THE DETAILS asked for in the FINALLY section at the troubleshooting link
    A fix via Virtual XP http://forums.adobe.com/thread/702693?tstart=0

  • 10g Automatic Stats Collection -- AUTO ( METHOD_OPT)

    I have implememted Oracle 10g Auto Stats collection feature. To generate new stats on 10g optimizer I deleted the schema stats and then scheduled the DBMS_SCHEDULER to collect stats in AUTO method_opt.
    I see that the new 10g optimizer is collecting stats differently in different databases eben through they have the same data.
    For exampl I see that it collected Histograms on 10 columns in one table in one environment but it generatd histograms only on 9 columns in another env.
    I am concerned that the stats difference will result in the execution plan getting changed across different instances.
    Can someone please clarify the cause of the same. How can I make sure tha the 10g optimizer is collecting stats uniformly across different envs.
    Thank You

    You wrote:
    "I am concerned that the stats difference will result in the execution plan getting changed across different instances."
    and you should be concerned.
    I would recommend not collecting stats the way you are but rather to use a nuanced approach where you collect only when they are stale or only when you know that changes have rendered old statistics invalid.

  • Query tuning in 10g

    In quey tuning
    1. purpose of optimizer mode
    2. why we need to take statistics and analyse tables and schemas
    I have been searching in the google but i didn't get solution.
    please help me.
    regards,
    rajesh

    1. purpose of optimizer mode
    Ans-> From 10g onwards default optimizer mode is all_rows which is cost based model. Prior to 10g default was "choose" which tell optimizer to use Rulebased model if statistics of objects are missing otherwise use cost based model.
    In 10g optimizer can have three values a) all_rows (cost will be calculated based on retuning all rows as soon as possible) b) first_rows (Cost will be calculated based on returning first row as soon as possible) c) first_rows_n (N is integer here and cost will be calculated to get N rows as soon as possible).
    2. why we need to take statistics and analyse tables and schemas
    In cost based model, optimizer need objects statistics to decide the best execution plans. Optimizer takes values like NULL,NDV,NUM_ROWS etc from dba_tables,dba_indexes etc to decide plans. If however these are not available then optimizer might get wrong execution plan because it take default values which could have hugh impact.
    Beside this optimizer takes other factors as well like Init parameters,system statistics,Hints.
    And here is the best artical available to explain about optimizer, please have a look. http://www.oracle.com/technetwork/database/focus-areas/bi-datawarehousing/twp-explain-the-explain-plan-052011-393674.pdf
    Regards

  • Performance Problem After upgrade to oracle 10g

    Hi
    I have upgrade one of my datawarehouse database from oracle 9.2.0.8 to oracle 10.2.0.4 running on solaris 9
    After the upgrade jobs which were running in the database is taking hell lot of time.
    The jobs are accessing the views which is used to get the monthly report data from the database.
    what could be the solution and where to start from to get the RCA to resolve this performance issue
    Please let me know if you require any other information
    database is currently running in the automatic shared memory management mode ie SGA_MAX and SGA_TARGET parameters are defined for that

    There are a lot of differences between 10g and 9i in this regard, among these are:
    - There is a default job that gathers statistics every night which is not there in 9i. You might have totally different statistics as in 9i due to that job, depending on how and if at all you used to collect statistics in 9i
    - The 10g DBMS_STATS package collects histograms on some columns by default (parameter METHOD_OPT=>'FOR ALL COLUMNS SIZE AUTO' default in 10g whereas 'FOR ALL COLUMNS SIZE 1' in 9i) which can have a significant effect on the execution plans
    - The 10g optimizer has CPU costing enabled by default which can make significant changes to your execution plans due to different costing of table scans and order of predicate evaluation. In addition it uses NOWORKLOAD system statistics if system statistics have not been gathered explicitly
    - 10g checks the min and max values stored for columns in the data dictionary. If your predicates are way off compared to these values then 10g begins to adjust the calculated selectivity of the predicate which can again significantly affect your execution plans
    - 10g introduces the "Cost Based Query Transformation (CBQT)" feature which means that rather than applying heuristic transformation rules transformations are costed and potentially discarded whereas 9i applies transformations unconditionally whenever possible
    Check also the following note resp. white paper:
    http://optimizermagic.blogspot.com/2008/02/upgrading-from-oracle-database-9i-to.html
    Regards,
    Randolf
    Oracle related stuff blog:
    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/

  • Slow performance after 10g upgrade

    After upgrade from 9.2.0.3.0 to 10.2.0.1.0, the following query runs extremely slow, any suggestion how to adjust the DB settings without re-writing this query
    SELECT SUM (ABS (ship_net_clc_amt))
    FROM ship_dtl
    WHERE order_section_number = '940007320686'
    AND SUBSTR (misc_charge_code, 1, 2) IN ('72', '77', 'A9')
    AND ics_status_flag2 IN ('W', 'S')
    AND dsr_trans_date >= to_date('1/1/2008', 'MM/DD/YYYY')
    AND dsr_trans_date < to_date('1/31/2008', 'MM/DD/YYYY')
    AND product_base_number NOT IN (SELECT DISTINCT sku
    FROM ap_smb_sku_based
    WHERE fiscal_period = '200801'
    AND country = 'TAIWAN')
    AND quota_product_line_code IN (SELECT pl
    FROM ap_pl_bu
    WHERE bu = '3C')
    The exec plan for 10g (optimizer mode = ALL ROWS) is
    ------------------------------------------------------------------------------------------------------------------------------|
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop ||
    ------------------------------------------------------------------------------------------------------------------------------|
    | 0 | SELECT STATEMENT | | 1 | 49 | 7 (15)| 00:00:01 | | ||
    | 1 | SORT AGGREGATE | | 1 | 49 | | | | ||
    |* 2 | FILTER | | | | | | | ||
    |* 3 | TABLE ACCESS BY LOCAL INDEX ROWID| SHIP_DTL | 1 | 42 | 1 (0)| 00:00:01 | 39 | 39 ||
    | 4 | NESTED LOOPS | | 1 | 49 | 5 (20)| 00:00:01 | | ||
    | 5 | SORT UNIQUE | | 1 | 7 | 3 (0)| 00:00:01 | | ||
    |* 6 | TABLE ACCESS FULL | AP_PL_BU | 1 | 7 | 3 (0)| 00:00:01 | | ||
    | 7 | PARTITION RANGE SINGLE | | 3 | | 0 (0)| 00:00:01 | 39 | 39 ||
    |* 8 | INDEX RANGE SCAN | IX_SHIP_DTL_ORD_SEC_NM | 3 | | 0 (0)| 00:00:01 | 39 | 39 ||
    | 9 | PARTITION RANGE SINGLE | | 1 | 39 | 2 (0)| 00:00:01 | 25 | 25 ||
    |* 10 | TABLE ACCESS FULL | AP_SMB_SKU_BASED | 1 | 39 | 2 (0)| 00:00:01 | 25 | 25 ||
    ------------------------------------------------------------------------------------------------------------------------------|
    The exec plan for 9i (optimizer mode=choose) for
    ----------------------------------------------------------------------------------------------------------------|
    | Id | Operation | Name | Rows | Bytes | Cost | Pstart| Pstop ||
    ----------------------------------------------------------------------------------------------------------------|
    | 0 | SELECT STATEMENT | | 1 | 47 | 10 | | ||
    | 1 | SORT AGGREGATE | | 1 | 47 | | | ||
    | 2 | FILTER | | | | | | ||
    | 3 | HASH JOIN SEMI | | 1 | 47 | 8 | | ||
    | 4 | TABLE ACCESS BY LOCAL INDEX ROWID| SHIP_DTL | 1 | 36 | 5 | 13 | 13 ||
    | 5 | INDEX RANGE SCAN | IX_SHIP_DTL_ORD_SEC_NR | 9 | | 3 | 13 | 13 ||
    | 6 | TABLE ACCESS FULL | AP_PL_BU | 2 | 22 | 2 | | ||
    | 7 | TABLE ACCESS FULL | AP_SMB_SKU_BASED | 1 | 21 | 2 | 13 | 13 ||
    Thanks.
    Liz

    ship_dtl has 94690531 records
    ap_smb_sku_based has 19 records
    ap_plbu has 19 records
    The query returns a single row, because it calculates the sum. The query could be better written to get rid of IN or NOT IN which are costly. But I just wonder why the plans/performance are so different?
    I used analyze to analyze other tables and it is still working fine in 10g. Now based on the plans, do you think anything wrong ?
    10g -
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------|
    | Id  | Operation                                   | Name                   | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |    TQ  |IN-OUT| PQ Distrib ||
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------|
    |   0 | SELECT STATEMENT                            |                        |     1 |    50 |    10 (-550| 00:00:01 |       |       |        |      |            ||
    |   1 |  SORT AGGREGATE                             |                        |     1 |    50 |            |          |       |       |        |      |            ||
    |*  2 |   FILTER                                    |                        |       |       |            |          |       |       |        |      |            ||
    |*  3 |    PX COORDINATOR                           |                        |       |       |            |          |       |       |        |      |            ||
    |   4 |     PX SEND QC (RANDOM)                     | :TQ10002               |     1 |    50 |    66   (5)| 00:00:01 |       |       |  Q1,02 | P->S | QC (RAND)  ||
    |*  5 |      FILTER                                 |                        |       |       |            |          |       |       |  Q1,02 | PCWC |            ||
    |   6 |       MERGE JOIN                            |                        |     1 |    50 |    66   (5)| 00:00:01 |       |       |  Q1,02 | PCWP |            ||
    |   7 |        SORT JOIN                            |                        |     2 |    14 |     4  (50)| 00:00:01 |       |       |  Q1,02 | PCWP |            ||
    |   8 |         BUFFER SORT                         |                        |       |       |            |          |       |       |  Q1,02 | PCWC |            ||
    |   9 |          PX RECEIVE                         |                        |     4 |    28 |     2   (0)| 00:00:01 |       |       |  Q1,02 | PCWP |            ||
    |  10 |           PX SEND HASH                      | :TQ10000               |     4 |    28 |     2   (0)| 00:00:01 |       |       |        | S->P | HASH       ||
    |  11 |            SORT UNIQUE                      |                        |     4 |    28 |     2   (0)| 00:00:01 |       |       |        |      |            ||
    |* 12 |             TABLE ACCESS FULL               | AP_PL_BU               |     4 |    28 |     2   (0)| 00:00:01 |       |       |        |      |            ||
    |* 13 |        SORT JOIN                            |                        |     1 |    43 |    62   (2)| 00:00:01 |       |       |  Q1,02 | PCWP |            ||
    |  14 |         PX RECEIVE                          |                        |     1 |    43 |    61   (0)| 00:00:01 |       |       |  Q1,02 | PCWP |            ||
    |  15 |          PX SEND HASH                       | :TQ10001               |     1 |    43 |    61   (0)| 00:00:01 |       |       |  Q1,01 | P->P | HASH       ||
    |  16 |           PX PARTITION RANGE ITERATOR       |                        |     1 |    43 |    61   (0)| 00:00:01 |   KEY |   KEY |  Q1,01 | PCWC |            ||
    |* 17 |            TABLE ACCESS BY LOCAL INDEX ROWID| SHIP_DTL               |     1 |    43 |    61   (0)| 00:00:01 |   KEY |   KEY |  Q1,01 | PCWP |            ||
    |* 18 |             INDEX RANGE SCAN                | IX_SHIP_DTL_ORD_SEC_NR |    14 |       |    49   (0)| 00:00:01 |   KEY |   KEY |  Q1,01 | PCWP |            ||
    |  19 |    PARTITION RANGE SINGLE                   |                        |     1 |    39 |     2   (0)| 00:00:01 |    14 |    14 |        |      |            ||
    |* 20 |     TABLE ACCESS FULL                       | AP_SMB_SKU_BASED       |     1 |    39 |     2   (0)| 00:00:01 |    14 |    14 |        |      |            ||
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------|Plan for 9i
    -----------------------------------------------------------------------------------------------------------------------------------------------|
    | Id  | Operation                              |  Name                   | Rows  | Bytes | Cost  | Pstart| Pstop |  TQ    |IN-OUT| PQ Distrib ||
    -----------------------------------------------------------------------------------------------------------------------------------------------|
    |   0 | SELECT STATEMENT                       |                         |     1 |    53 |    74 |       |       |        |      |            ||
    |   1 |  SORT AGGREGATE                        |                         |     1 |    53 |       |       |       |        |      |            ||
    |   2 |   FILTER                               |                         |       |       |       |       |       |        |      |            ||
    |   3 |    FILTER                              |                         |       |       |       |       |       |        |      |            ||
    |   4 |     HASH JOIN SEMI                     |                         |     1 |    53 |    72 |       |       | 30,01  | P->S | QC (RAND)  ||
    |   5 |      PARTITION RANGE ITERATOR          |                         |       |       |       |   KEY |   KEY | 30,01  | PCWP |            ||
    |   6 |       TABLE ACCESS BY LOCAL INDEX ROWID| SHIP_DTL                |     1 |    42 |    54 |   KEY |   KEY | 30,01  | PCWP |            ||
    |   7 |        INDEX RANGE SCAN                | IX_SHIP_DTL_ORD_SEC_NR  |    21 |       |    37 |   KEY |   KEY | 30,01  | PCWP |            ||
    |   8 |      TABLE ACCESS FULL                 | AP_PL_BU                |     2 |    22 |     2 |       |       | 30,00  | S->P | BROADCAST  ||
    |   9 |    TABLE ACCESS FULL                   | AP_SMB_SKU_BASED        |     1 |    39 |     2 |    14 |    14 |        |      |            ||
    -----------------------------------------------------------------------------------------------------------------------------------------------|

Maybe you are looking for