CBO QUERY IN RBO DB

Hi,
One of our client is in (OPtimizer_mode = RBO) RBO in ORACLE 9I-DB. Four-Queries in a STORE PACKAGE are taking long time. I want utilize teh features of CBO only for those 4 queries. So I am planning to suggest them to change that 4 queriies with hint (ALL_ROWS). And sugesting them to gather statistics for only the related tables.
Please let me,
(1) Gathering statistics only for 4 of 50 tables is fine in oracle 9i-DB? Or will it create any other problem?
(2) I guess, Four queries in which I have added ALL_ROWS-comment will use CBO. And other queries (which are not having comment ALL_ROWS) related the four table and all other queries will not have any problem they will in RBO as it is (which is expected). Is it right? If any issue please let me know?
With Thanks & Regards
K.Sundar

870860 wrote:
Hi,
One of our client is in (OPtimizer_mode = RBO) RBO in ORACLE 9I-DB. Four-Queries in a STORE PACKAGE are taking long time. I want utilize teh features of CBO only for those 4 queries. So I am planning to suggest them to change that 4 queriies with hint (ALL_ROWS). And sugesting them to gather statistics for only the related tables.
Please let me,
(1) Gathering statistics only for 4 of 50 tables is fine in oracle 9i-DB? Or will it create any other problem?Gathering statistics is done for the CBO, so shouldn't effect anything with the RBO.
http://docs.oracle.com/cd/B10501_01/server.920/a96533/stats.htm
(2) I guess, Four queries in which I have added ALL_ROWS-comment will use CBO. And other queries (which are not having comment ALL_ROWS) related the four table and all other queries will not have any problem they will in RBO as it is (which is expected). Is it right? If any issue please let me know?In theory, that is correct.
http://docs.oracle.com/cd/B10501_01/server.920/a96533/hintsref.htm#4924
Is there a particular reason your client is still using RBO rather than CBO?

Similar Messages

  • How to tune the query and difference between CBO AND RBO.. Which is good

    Hello Friends,
    Here are some questions I have pls reply back with complete description and url if any ..
    1)How Did you tune Query,
    2)What approach you take to tune query? Do you use Hints?
    3)Where did you tune the query and what are the issue with query?
    4)What is difference between RBO and CBO? where u use RBO and CBO.
    5)Give some information about hash join?
    6) Using explain plan how do u know where the bottle neck in query .. how u will identify where the bottle neck is from explain plan .
    thanks/Kumar

    Hi,
    kumar73 wrote:
    Hello Friends,
    Here are some questions I have pls reply back with complete description and url if any ..
    1)How Did you tune Query, Use EXPLAIN PLAN to see exactly where it is spending its time, and address those areas.
    See the forum FAQ
    SQL and PL/SQL FAQ
    "3. How to improve the performance of my query?"
    2)What approach you take to tune query? Do you use Hints?Hints can help.
    Even more helpful is writing the SQL efficiently (avoiding multiple scans of the same table, filtering early, using built-in rather than user-defined functions, ...), creating and using indexes, and, for large tables, partitioning.
    Table design can have a big impact on performace.
    Look for ways to do part of what you need before the query. This includes denormalizing (when appropriate), the kind of pre-digesting that often takes place in data warehouses, function-based indexes, and, starting in Oracle 11, virtual columns.
    3)Where did you tune the query and what are the issue with query?Either this question is a vague summary of the entire thread, or I don't understand it. Can you re-phrase this part?
    4)What is difference between RBO and CBO? where u use RBO and CBO.Basically, use RBO if you have Oracle 7 or earlier.

  • Cbo plan

    Pls tell me how the execution plan execute in CBO.
    from RBO Is right to left.
    I am runing one query is RBO as well as CBO Plan is different
    sequence of table access is different.
    Thanks
    Reena

    Hi,
    which version of Oracle are you runnning,
    In CBO the optimizer will determine the driving table. The CBO will determine upon the COST which will be the driving table which will be derermined by the INDEXES, the Statistics of the table and other parameters.
    Where as in RBO the table from the right in the FORM clause will be the driving table.
    thanks

  • Query to find the biggest table in the database..!!!

    Hello everybody,
    i have more than 600 tables in the database i need to find the biggest table in the database and want to order it in descending pattern..
    Is there any query for this task...
    Rgds
    Harsh.

    What version of Oracle? Do you use the CBO or the RBO? If you use the CBO, are your statistics accurate? Can you tolerate having approximate rowcounts?
    SELECT table_name, num_rows
      FROM user_tables
    ORDER BY num_rowsmay be what you're looking for, but
    - num_rows is populated when you gather statistics, so it'll be empty if you're using the RBO
    - num_rows may be an approximate number, depending on how you're gathering statistics
    - num_rows only reflects the size at the instant you gathered statistics. It is not maintained in real time.
    I'm guessing, though, that this is close enough for whatever you're doing.
    Justin

  • Tuning of a view

    Hi,
    Below is the view used in cursor with order by clause. Its taking lot of time for teching rows.
    Could anyone help to tune this view. so that performace can be improved.
    If I remove rule based optimzer hint and checked explain plan for CBO. Its doing many full table scans and also its kaing more time then rule based.
    CREATE OR REPLACE VIEW V_FIF AS
    SELECT  /*+ rule */
            ml_level_type                   fif_ml,
            ifs.if_ml_id                    fif_ml_id,
            ifs.if_id                       fif_if_id,
            ifs.if_type                     fif_if_type,
            ifs.if_min_stock_level          fif_min_stock_level,
            ifs.if_max_stock_level          fif_max_stock_level,
            ifs.if_mi_id                    fif_mi_id,
            ifs.if_std_produced_qty         fif_if_std_produced_qty,
            ifs.if_lotsize                  fif_if_lotsize,
            ifs.if_successor_qty            fif_successor_qty,
            ifs.if_successor_base_qty       fif_successor_base_qty,
            ifs.if_successor_uom            fif_successor_uom,
            ifs.if_if_id                    fif_if_if_id,
            ifs.if_valid_flag               fif_valid_flag,
            ifs.if_freeze_fence             fif_freeze_fence,
            ifs.if_freeze_fence_date        fif_freeze_fence_date,
            ifs.if_freeze_fence_date_old    fif_freeze_fence_date_old,
            ifs.if_facility_planning_flag   fif_facility_planning_flag,
            ifs.if_deletion_mark            fif_if_deletion_mark,
         ifs.if_allocation_fence_date     fif_allocation_fence_date,
            ifs.misr_id                     fif_misr_id,
            ifs.misr_me_id                  fif_me_id,
            ifs.item_mat_id                 fif_item_mat_id,
            ifs.item_prit_id                fif_item_prit_id,
            ifs.item_papl_id                fif_item_papl_id,
            ifs.item_repi_id                fif_item_repi_id,
            ifs.item_tnr                    fif_item_tnr,
            ifs.item_id                     fif_item_id,
            ifs.btyp_id                     fif_btyp_id,
            ifs.btyp_basic_type             fif_basic_type,
            sprd_sales_name                 fif_sprd_sales_name,
            bno_id                          fif_bno_id,
            bno_baunumber                   fif_bno,
            bno_deletion_mark               fif_bno_deletion_mark,
            bno_demand_level_code           fif_bno_demand_level_code,
            pg_id                           fif_pg_id,
            pl_process_line                 fif_pl_process_line,
            pl_id                           fif_pl_id,
            pcl_process_class               fif_pcl_process_class,
            pcl_id                          fif_pcl_id,
            pgp_id                          fif_pgp_id,
            DECODE(bs1.bs_id, NULL,DECODE(bs2.bs_id, NULL, bs3.bs_id, bs2.bs_id), bs1.bs_id)        fif_bs_id,
            DECODE(bs1.bs_business_segment, NULL,
                    DECODE(bs2.bs_business_segment, NULL, bs3.bs_business_segment, bs2.bs_business_segment), bs1.bs_business_segment) fif_bs_business_segment,
            fac_id                          fif_fac_id,
            fac_facility_name               fif_fac_name,
            fac_facility_type               fif_fac_type,
            fac_usable_from                 fif_fac_usable_from,
            fac_usable_to                   fif_fac_usable_to,
            fac_loc_id                      fif_fac_loc_id,
            loc_location                    fif_fac_loc_location,
            si1.site_id                     fif_site_id,
            si1.site_site_name              fif_site_name,
            si2.site_id                     fif_site_id_fm,
            si2.site_site_name              fif_site_name_fm,
            sc1.sc_id                       fif_sc_id,
            sc1.sc_supply_chain_name        fif_sc_name,
            sc1.sc_type                     fif_sc_type,
            sc1.sc_eng_id                   fif_sc_eng_id,
            sc2.sc_id                       fif_sc_id_fm,
            sc2.sc_supply_chain_name        fif_sc_name_fm,
            sc2.sc_type                     fif_sc_type_fm,
            sc2.sc_eng_id                   fif_sc_eng_id_fm,
            pk_id                           fif_pk_id,
            pk_package_name                 fif_package_name,
            eng_ignore_key_wc               fif_eng_ignore_key_wc,
            dbi_id                          fif_dbi_id,
            bno_rias_user                   fif_bno_rias_user,
            bno_production_arranger         fif_bno_production_arranger
          , if_merchandise_flag             fif_merchandise_flag
    FROM
            (SELECT
                    ifsel.*,
                    misr_id,
                    misr_me_id,
                    item_mat_id,
                    item_prit_id,
                    item_papl_id,
                    item_repi_id,
                    item_tnr,
                    item_id,
                    item_sisc_id,
                    me_pk_id,
                    decode (if_misr_id, null, nvl(btyp2.btyp_id,0), btyp1.btyp_id)                          btyp_id,
                    decode (if_misr_id, null, nvl(btyp2.btyp_basic_type, 'UNDEF.'), btyp1.btyp_basic_type)  btyp_basic_type,
                    decode (if_misr_id, null, nvl(btyp2.btyp_pl_id, 0), btyp1.btyp_pl_id)                   btyp_pl_id
            FROM
                    basic_types     btyp1,
                    basic_types     btyp2,
                    processed_items,
                    items,
                    mi_subroutes,
                    mi_elements,
                    item_facilities ifsel
            WHERE
                        ifsel.if_item_id = item_id
                    AND ifsel.if_misr_id = misr_id(+)
                    AND item_prit_id = prit_id (+)
                    AND prit_btyp_id = btyp2.btyp_id (+)
                    AND misr_me_id = me_id(+)
                    AND me_btyp_id = btyp1.btyp_id(+)
                    AND ifsel.if_type <> 'K'
                    AND
                               (item_prit_id is not null
                            OR item_repi_id is not null
                            OR item_sisc_id is not null)) ifs,
            manufacturing_levels,
            start_item_scs,
            business_segments bs3,
            sites si1,
            supply_chains sc1,
            sites si2,
            supply_chains sc2,
            engines,
            database_instances,
            facilities,
            locations,
            packages,
            representative_items,
            business_segments bs2,
            process_lines,
            process_groups,
            process_classes,
            baunumbers,
            product_groups,
            business_segments bs1,
            sales_products
    WHERE
                ifs.if_ml_id = ml_id
            AND ml_level_type <> 'UNDEF'
            AND ifs.item_sisc_id  = sisc_id(+)
            AND sisc_bs_id = bs3.bs_id(+)
            AND ifs.if_site_id = si1.site_id(+)
            AND si1.site_sc_id = sc1.sc_id(+)
            AND si1.site_site_id = si2.site_id(+)
            AND si2.site_sc_id = sc2.sc_id(+)
            AND sc2.sc_eng_id = eng_id(+)
            AND eng_dbi_id = dbi_id(+)
            AND ifs.if_fac_id = fac_id
            AND fac_loc_id = loc_id
            AND ifs.me_pk_id = pk_id(+)
            AND ifs.item_repi_id = repi_id(+)
            AND repi_bs_id = bs2.bs_id(+)
            AND ifs.btyp_pl_id = pl_id(+)
            AND pl_pgp_id = pgp_id (+)
            AND pgp_pcl_id = pcl_id (+)
            AND ifs.if_bno_id = bno_id(+)
            AND bno_pg_id = pg_id(+)
            AND pg_bs_id = bs1.bs_id(+)
            AND ifs.if_bno_id = sprd_bno_id(+)
            AND (bs1.bs_id is not null OR bs2.bs_id is not null OR bs3.bs_id is not null)
            AND (bno_baunumber is not null OR ifs.item_tnr is not null)
            AND (bno_deletion_mark is null OR ml_level_type = 'VKL')
    Explain plan for select * from v_fif order by fif_if_id;
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 62762906
    | Id  | Operation                                                 | Name
    |   0 | SELECT STATEMENT                                          |
    |   1 |  SORT ORDER BY                                            |
    |   2 |   NESTED LOOPS                                            |
    |*  3 |    FILTER                                                 |
    |   4 |     NESTED LOOPS OUTER                                    |
    |   5 |      NESTED LOOPS OUTER                                   |
    |   6 |       NESTED LOOPS OUTER                                  |
    |   7 |        NESTED LOOPS OUTER                                 |
    |   8 |         NESTED LOOPS OUTER                                |
    |   9 |          NESTED LOOPS OUTER                               |
    |  10 |           NESTED LOOPS OUTER                              |
    |  11 |            NESTED LOOPS OUTER                             |
    |  12 |             NESTED LOOPS                                  |
    |  13 |              NESTED LOOPS                                 |
    |  14 |               NESTED LOOPS OUTER                          |
    PLAN_TABLE_OUTPUT
    |  15 |                NESTED LOOPS OUTER                         |
    |  16 |                 NESTED LOOPS OUTER                        |
    |  17 |                  NESTED LOOPS OUTER                       |
    |  18 |                   NESTED LOOPS OUTER                      |
    |  19 |                    NESTED LOOPS OUTER                     |
    |  20 |                     NESTED LOOPS OUTER                    |
    |  21 |                      NESTED LOOPS OUTER                   |
    |  22 |                       NESTED LOOPS OUTER                  |
    |  23 |                        NESTED LOOPS OUTER                 |
    |  24 |                         VIEW                              |
    |  25 |                          NESTED LOOPS OUTER               |
    |  26 |                           NESTED LOOPS OUTER              |
    |  27 |                            NESTED LOOPS OUTER             |
    |  28 |                             NESTED LOOPS                  |
    |  29 |                              NESTED LOOPS OUTER           |
    |  30 |                               NESTED LOOPS OUTER          |
    |* 31 |                                TABLE ACCESS FULL          | ITEM_FACILIT
    |  32 |                                TABLE ACCESS BY INDEX ROWID| MI_SUBROUTES
    |* 33 |                                 INDEX UNIQUE SCAN         | MISR_PK
    |  34 |                               TABLE ACCESS BY INDEX ROWID | MI_ELEMENTS
    |* 35 |                                INDEX UNIQUE SCAN          | ME_PK
    PLAN_TABLE_OUTPUT
    |* 36 |                              TABLE ACCESS BY INDEX ROWID  | ITEMS
    |* 37 |                               INDEX UNIQUE SCAN           | ITEM_PK
    |  38 |                             TABLE ACCESS BY INDEX ROWID   | PROCESSED_IT
    |* 39 |                              INDEX UNIQUE SCAN            | PRIT_PK
    |  40 |                            TABLE ACCESS BY INDEX ROWID    | BASIC_TYPES
    |* 41 |                             INDEX UNIQUE SCAN             | BTYP_PK
    |  42 |                           TABLE ACCESS BY INDEX ROWID     | BASIC_TYPES
    |* 43 |                            INDEX UNIQUE SCAN              | BTYP_PK
    |  44 |                         TABLE ACCESS BY INDEX ROWID       | SALES_PRODUC
    |* 45 |                          INDEX UNIQUE SCAN                | SPRD_SPRD1_U
    |  46 |                        TABLE ACCESS BY INDEX ROWID        | BAUNUMBERS
    |* 47 |                         INDEX UNIQUE SCAN                 | BNO_PK
    |  48 |                       TABLE ACCESS BY INDEX ROWID         | PRODUCT_GROU
    |* 49 |                        INDEX UNIQUE SCAN                  | PG_PK
    |  50 |                      TABLE ACCESS BY INDEX ROWID          | BUSINESS_SEG
    |* 51 |                       INDEX UNIQUE SCAN                   | BS_PK
    |  52 |                     TABLE ACCESS BY INDEX ROWID           | PROCESS_LINE
    |* 53 |                      INDEX UNIQUE SCAN                    | PL_PK
    |  54 |                    TABLE ACCESS BY INDEX ROWID            | PROCESS_GROU
    |* 55 |                     INDEX UNIQUE SCAN                     | PGP_PK
    |  56 |                   TABLE ACCESS BY INDEX ROWID             | PROCESS_CLAS
    PLAN_TABLE_OUTPUT
    |* 57 |                    INDEX UNIQUE SCAN                      | PCL_PK
    |  58 |                  TABLE ACCESS BY INDEX ROWID              | REPRESENTATI
    |* 59 |                   INDEX UNIQUE SCAN                       | REPI_PK
    |  60 |                 TABLE ACCESS BY INDEX ROWID               | BUSINESS_SEG
    |* 61 |                  INDEX UNIQUE SCAN                        | BS_PK
    |  62 |                TABLE ACCESS BY INDEX ROWID                | PACKAGES
    |* 63 |                 INDEX UNIQUE SCAN                         | PK_PK
    |  64 |               TABLE ACCESS BY INDEX ROWID                 | FACILITIES
    |* 65 |                INDEX UNIQUE SCAN                          | FAC_PK
    |  66 |              TABLE ACCESS BY INDEX ROWID                  | LOCATIONS
    |* 67 |               INDEX UNIQUE SCAN                           | LOC_PK
    |  68 |             TABLE ACCESS BY INDEX ROWID                   | SITES
    |* 69 |              INDEX UNIQUE SCAN                            | SITE_PK
    |  70 |            TABLE ACCESS BY INDEX ROWID                    | SITES
    |* 71 |             INDEX UNIQUE SCAN                             | SITE_PK
    |  72 |           TABLE ACCESS BY INDEX ROWID                     | SUPPLY_CHAIN
    |* 73 |            INDEX UNIQUE SCAN                              | SC_PK
    |  74 |          TABLE ACCESS BY INDEX ROWID                      | ENGINES
    |* 75 |           INDEX UNIQUE SCAN                               | ENG_PK
    |* 76 |         INDEX UNIQUE SCAN                                 | DBI_PK
    |  77 |        TABLE ACCESS BY INDEX ROWID                        | SUPPLY_CHAIN
    PLAN_TABLE_OUTPUT
    |* 78 |         INDEX UNIQUE SCAN                                 | SC_PK
    |  79 |       TABLE ACCESS BY INDEX ROWID                         | START_ITEM_S
    |* 80 |        INDEX UNIQUE SCAN                                  | SISC_PK
    |  81 |      TABLE ACCESS BY INDEX ROWID                          | BUSINESS_SEG
    |* 82 |       INDEX UNIQUE SCAN                                   | BS_PK
    |* 83 |    TABLE ACCESS BY INDEX ROWID                            | MANUFACTURIN
    |* 84 |     INDEX UNIQUE SCAN                                     | ML_PK
    Predicate Information (identified by operation id):
       3 - filter("BS1"."BS_ID" IS NOT NULL OR "BS2"."BS_ID" IS NOT NULL OR
                  "BS3"."BS_ID" IS NOT NULL)
      31 - filter("IFSEL"."IF_TYPE"<>'K')
      33 - access("IFSEL"."IF_MISR_ID"="MISR_ID"(+))
      35 - access("MISR_ME_ID"="ME_ID"(+))
      36 - filter("ITEM_PRIT_ID" IS NOT NULL OR "ITEM_REPI_ID" IS NOT NULL OR
                  "ITEM_SISC_ID" IS NOT NULL)
      37 - access("IFSEL"."IF_ITEM_ID"="ITEM_ID")
      39 - access("ITEM_PRIT_ID"="PRIT_ID"(+))
    PLAN_TABLE_OUTPUT
      41 - access("PRIT_BTYP_ID"="BTYP2"."BTYP_ID"(+))
      43 - access("ME_BTYP_ID"="BTYP1"."BTYP_ID"(+))
      45 - access("IFS"."IF_BNO_ID"="SPRD_BNO_ID"(+))
      47 - access("IFS"."IF_BNO_ID"="BNO_ID"(+))
      49 - access("BNO_PG_ID"="PG_ID"(+))
      51 - access("PG_BS_ID"="BS1"."BS_ID"(+))
      53 - access("IFS"."BTYP_PL_ID"="PL_ID"(+))
      55 - access("PL_PGP_ID"="PGP_ID"(+))
      57 - access("PGP_PCL_ID"="PCL_ID"(+))
      59 - access("IFS"."ITEM_REPI_ID"="REPI_ID"(+))
      61 - access("REPI_BS_ID"="BS2"."BS_ID"(+))
      63 - access("IFS"."ME_PK_ID"="PK_ID"(+))
      65 - access("IFS"."IF_FAC_ID"="FAC_ID")
      67 - access("FAC_LOC_ID"="LOC_ID")
      69 - access("IFS"."IF_SITE_ID"="SI1"."SITE_ID"(+))
      71 - access("SI1"."SITE_SITE_ID"="SI2"."SITE_ID"(+))
      73 - access("SI2"."SITE_SC_ID"="SC2"."SC_ID"(+))
      75 - access("SC2"."SC_ENG_ID"="ENG_ID"(+))
      76 - access("ENG_DBI_ID"="DBI_ID"(+))
      78 - access("SI1"."SITE_SC_ID"="SC1"."SC_ID"(+))
      80 - access("IFS"."ITEM_SISC_ID"="SISC_ID"(+))
    PLAN_TABLE_OUTPUT
      82 - access("SISC_BS_ID"="BS3"."BS_ID"(+))
      83 - filter(("BNO_DELETION_MARK" IS NULL OR "ML_LEVEL_TYPE"='VKL') AND
                  "ML_LEVEL_TYPE"<>'UNDEF')
      84 - access("IFS"."IF_ML_ID"="ML_ID")
    Note
       - rule based optimizer used (consider using cbo)
    133 rows selectedAny help really appreciated
    Thanks in advance

    I will suggest two things for your problem.
    1. Try to remove all the decode operation with case .
    2. If possible use CBO instead of RBO.
    As you said that CBO is taking more time .. You must gather statistics about the objects.
    and then use the CBO.
    And a full table scan not always stands for the performance problems.It depends on the cardinality of
    your SQL Statement.
    Your explain plan output also shows a view operation is taking place, so try to rewrite the view in some other
    possible way so that the view can become mergable with the main query.
    It will defenitely help you.
    Bi tc

  • Explain Plan and Execution Plan in 10gR2.

    Hi,
    Version 10.2.0.1.0.
    I have two questions:
    1) If the explain plan differs from the execution path in this version, then, is it safe to assume that the statistics are stale (or not gathered at all) on the underlying tables?
    2) Can you in any way make a query use RBO instead of CBO? (I know it doesn't make any sense since CBO is lot smarter, but, for purely academic reasons).
    Thank you,
    Rahul.

    The rule based optimizer is most definitely present in 10gR2. It might not be in the documentation, but it is still there.
    C:\sql>sqlplus test/test
    SQL*Plus: Release 10.2.0.2.0 - Production on Tue Oct 10 15:43:34 2006
    Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    test@SVTEST> set autotrace traceonly
    test@SVTEST> alter session set optimizer_mode=rule;
    Session altered.
    Elapsed: 00:00:00.01
    test@SVTEST> select * from dual;
    Elapsed: 00:00:00.03
    Execution Plan
    Plan hash value: 272002086
    | Id | Operation | Name |
    | 0 | SELECT STATEMENT | |
    | 1 | TABLE ACCESS FULL| DUAL |
    Note
    - rule based optimizer used (consider using cbo)
    Statistics
    1 recursive calls
    0 db block gets
    3 consistent gets
    2 physical reads
    0 redo size
    407 bytes sent via SQL*Net to client
    381 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    1 rows processed
    test@SVTEST>

  • Planning to start the performance tuning but....

    Friends,
    Database OS: RHEL AS 3.0
    Database: Oracle Release 9.2.0.4.0
    Number of Tables: 503
    TableSpace size - 1.8GB out of 3GB
    Max.Records in a Table - 1 Million and its increasing..
    Our DB Optimizer mode is - CHOOSE (is it RBO?)
    We are not using enterprise manager and not installed any tuning scripts like statspack etc....
    Currently we are taking user managed backup without any problem so we are continuing the same from 2004 onwards.
    Now we want want to tune our database.(We have never tuned our database)
    We would like to change our optimizer from RBO to CBO.
    Can anybody tell me the first step for the performance tuning?
    Please dont suggest me oracle doc im already studying.....its taking time....
    In the mean time......
    Step 1: Can i Analyze the table or dbms_stat package?
    We have not at all used the analyze or dbms_stat. So can i start with any of the above or do u have any other suggestions for the 1st step?
    Thanks

    our manager feels that if we tune our db the performance will be more than compared to the current one.you have a mystique manager then, ask him what kind of "feelings" does he have about my database ;) there is no place for feelings in this game, this is life cycle to be successful ; testing->reporting->analyzing->take nedded actions->re-testing->reporting->analyzing..
    so while you are surely reading the documentation;
    Oracle9i Database Performance Planning Release 2 (9.2)
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96532/toc.htm
    Oracle9i Database Performance Tuning Guide and Reference Release 2 (9.2)
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96533/toc.htm
    first thing you have to do is to setup an appropriate test environment with same os-oracle releases, parameters;
    -- some of them to check
    SELECT NAME, VALUE
      FROM v$system_parameter a
    WHERE a.NAME IN
           ('compatible', 'optimizer_features_enable',
            'optimizer_mode', 'pga_aggregate_target', 'workarea_size_policy',
            'db_file_multiblock_read_count', .. )and of course schema set and data amount. Then you run your application on load and take statspack snapshots and do the same after collecting statistics;
    -- customize for your configuration, schema level object statistics
    exec dbms_stats.gather_schema_stats( ownname =>'YOUR_SCHEMA', degree=>16, options=>'GATHER AUTO', estimate_percent=>dbms_stats.auto_sample_size, cascade=>TRUE, method_opt=>'FOR ALL COLUMNS SIZE AUTO', granularity=>'ALL');
    -- check your system stats, with sys account
    SELECT pname, pval1 FROM sys.aux_stats$ WHERE sname = 'SYSSTATS_MAIN';after you have the base report and the report after change compare the top 5 waits, the top queries which have dramatic logical I/O changes etc. At this point you go into session based tuning in order to understand why a specific query performs worser with CBO compared to RBO. You need to be able to create and read execution plans and i/o statistics at least. Here are some quick introductions;
    http://www.bhatipoglu.com/entry/17/oracle-performance-analysis-tracing-and-performance-evaluation
    http://psoug.org/reference/explain_plan.html
    http://coskan.wordpress.com/2007/03/04/viewing-explain-plan/
    and last words again goes to your manager; how does he "feel" about a 10gR2 migration? With Grid Control, AWR, ADDM and ASH performance tuning evolved a lot. Important note here, after 10g RBO is dead(unsupported).
    Best Regards,
    H.Tonguç YILMAZ
    http://tonguc.yilmaz.googlepages.com/
    Message was edited by:
    TongucY

  • How bright is the display and difference between MacBook Pro

    I have not decided which MacBook/Pro I will buy. An issue is the display. The display of my old 500Mhz G3 ibook looks quite dim compared to external displays.
    Usual you find the specs for the brightness (eg 300cd/m2) and contrast ratio's (1:800) in the technical data sheets. However, I couln't find this information for the MacBook or MacBook Pro. Does anyone know this values and how do they compare to iMac or the Apple Display (I still have the feeling that external displays are much brighter).
    My second question is, how compares the MaBook display to the MacBook Pro (glossy), besides the different size. I will definite go for a Pro in case the display of the Pro is much better.
    Many thanks
    ibook G3, 500Mhz, 640MByte Ram   Mac OS X (10.4)  

    Hi,
    kumar73 wrote:
    Hello Friends,
    Here are some questions I have pls reply back with complete description and url if any ..
    1)How Did you tune Query, Use EXPLAIN PLAN to see exactly where it is spending its time, and address those areas.
    See the forum FAQ
    SQL and PL/SQL FAQ
    "3. How to improve the performance of my query?"
    2)What approach you take to tune query? Do you use Hints?Hints can help.
    Even more helpful is writing the SQL efficiently (avoiding multiple scans of the same table, filtering early, using built-in rather than user-defined functions, ...), creating and using indexes, and, for large tables, partitioning.
    Table design can have a big impact on performace.
    Look for ways to do part of what you need before the query. This includes denormalizing (when appropriate), the kind of pre-digesting that often takes place in data warehouses, function-based indexes, and, starting in Oracle 11, virtual columns.
    3)Where did you tune the query and what are the issue with query?Either this question is a vague summary of the entire thread, or I don't understand it. Can you re-phrase this part?
    4)What is difference between RBO and CBO? where u use RBO and CBO.Basically, use RBO if you have Oracle 7 or earlier.

  • Beginner question(s) on statistics?

    I'm working with an old database (version 8i) that is still in use, but being phased out, and I'm experiencing performance problems when querying it. (FYI, I'm not the DBA, I just query data out of the database.) Usually, for simple queries, performance is acceptable, except on some of the larger tables (> 1 million rows). I know the default optimizer mode is rule-based, but I know I can use the choose hint to force using the CBO. I checked to see when statistics were last generated for some of the tables involved in slow queries, and 'last_analyzed' is blank for some of the tables, and over two years old for others (none newer than that at all). I'm assuming this is bad. I'd like to notify someone to remedy this problem, but I'd like to at least know what I'm talking about when I ask...
    So...
    Should statistics be generated for every table, or just some?
    Are there restrictions on whether or not statistics can be generated?
    Are there any guidelines on how often statistics should be generated/how do you know that statistics are too old?
    Can statistics be generated while the database being used? (i.e. the application using the database is writing to it, and people are accessing it)
    Is there anything else important I should know in order to intelligently request this to be fixed?

    >
    Justin Cave wrote:
    If you are going to use the CBO, every object (tables and indexes) should have statistics. The CBO can gather limited statistics during the parse phase if statistics are missing (dynamic statistics generation) but this is generally not particularly accurate.
    >
    In my opinion, there's no need to switch to the CBO. The RBO performs just fine most of the time. It's probably about 20% of the time it doesn't perform acceptably. It's more that I want the option to use the CBO if the RBO performs badly.
    >
    Justin Cave wrote:
    Personally, I'd phrase it (at least initially) as more of a question to the DBAs about why some objects have statistics while others don't. If the DBAs have good reasons for making the decisions that have been made, there may not be anything to fix (particularly assuming that the applications that are still using this database are more important than your queries). If the DBAs reply that this state of affairs wasn't intentional, they'll probably be happy to take responsibility for fixing it.
    >
    The (tiny) IT dept has undergone multiple personnel/management changes since this database was initially introduced, and they have at least 4 old (3 8i, 1 9i, plus God knows what else) databases and multiple crippled systems to deal with. I would guess the majority of their time is spent fighting fires and trying to upgrade systems, rather than doing maintenance (except possibly what's absolutely necessary, though my guess is, that doesn't even get done, thus some of the fire-fighting). The current people don't seem to know Oracle any better than I do (though I could be wrong), and I think the DBA role has been contracted out, and may possibly only be called in when there's a problem the local folks can't fix. I'm fairly certain the last time statistics were run on any of the tables were prior to the current management, so I doubt they know why one table or another does or does not have statistics, but I suppose it can't hurt to ask. Given the overburdened IT department, I try to point things out when I can, and provide as much relevant information to fixing a problem, especially when the issues impact more than just me.
    >
    Justin Cave wrote:
    One option to keep in mind-- might it be possible to replicate the data you need to query to a different database (or to a different set of tables) where you could freely gather statistics without worrying about affecting legacy applications?
    >
    I am trying to do something like this in my own little test environment. I have XE 10g installed on my local machine. That's great for me, but quite often I get asked to prepare reports for other people. Usually, I don't have problems going against the 8i database, but on the occasion that I do, I don't want to have to create a report against my test environment, because then, anytime someone wanted that report run, I'd have to do it for them, which, let's be honest, is a waste of my time. I have futilely asked for a test environment in the past, which is part of the reason I installed XE on my own computer. I'm hoping that once I finish putting together my own test environment, I might be able to supply my code to the IT department to make it easier for them to create a public test environment / query environment so that it might actually happen.
    I was hoping asking for statistics to be generated might be an easier request to start with...

  • RULE HINT 11.2

    Version Details
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE 11.2.0.3.0 Production
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    I have inherited this code in a package and was looking at the explain plan contains a Hint that is RULE , the database is 11.2 is it still valid, can anyone give me some advice on how to improve the below query?
    | Id  | Operation                        | Name                       |
    |   0 | SELECT STATEMENT                 |                            |
    |   1 |  SORT AGGREGATE                  |                            |
    |*  2 |   INDEX RANGE SCAN               | PARCEL_HISTORY_HOLDING_PF1 |
    |   3 |  NESTED LOOPS OUTER              |                            |
    |   4 |   NESTED LOOPS OUTER             |                            |
    |   5 |    NESTED LOOPS OUTER            |                            |
    |*  6 |     FILTER                       |                            |
    |   7 |      NESTED LOOPS OUTER          |                            |
    |   8 |       TABLE ACCESS BY INDEX ROWID| PARCEL_HISTORY_HOLDING     |
    |   9 |        INDEX FULL SCAN           | PARCEL_HISTORY_HOLDING_PF1 |
    |  10 |       TABLE ACCESS BY INDEX ROWID| PARCELS                    |
    |* 11 |        INDEX UNIQUE SCAN         | PARCELS_PK                 |
    |  12 |     TABLE ACCESS BY INDEX ROWID  | PARCEL_ADDRESSES           |
    |* 13 |      INDEX UNIQUE SCAN           | PARCEL_ADDRESSES_PK        |
    |  14 |    TABLE ACCESS BY INDEX ROWID   | PARCEL_ADDRESSES           |
    |* 15 |     INDEX UNIQUE SCAN            | PARCEL_ADDRESSES_PK        |
    |* 16 |   INDEX UNIQUE SCAN              | PARCEL_HISTORY_PIVOT_PK    |
    Predicate Information (identified by operation id):
       2 - access("PH"."PARCEL_ID"=:B1)
       6 - filter("P"."PARCEL_ID" IS NOT NULL)
      11 - access("PHH"."PARCEL_ID"="P"."PARCEL_ID"(+))
      13 - access("PAC"."PARCEL_ID"(+)="P"."PARCEL_ID" AND
                  "PAC"."ADDRESS_TYPE"(+)='COL')
      15 - access("PAD"."PARCEL_ID"(+)="P"."PARCEL_ID" AND
                  "PAD"."ADDRESS_TYPE"(+)='DEL')
      16 - access("PHH"."PARCEL_ID"="PP"."PARCEL_ID"(+))
    Note
       - rule based optimizer used (consider using cbo)
    QUERY
         SELECT   /*+ rule */
                         phh.ROWID tabrow
                        ,phh.parcel_id
                        ,phh.scan_date
                        ,phh.status_code
                        ,phh.reason_code
                        ,phh.app_code
                        ,phh.scan_id
                        ,phh.location_code
                        ,phh.card_id
                        ,phh.signature_captured
                        ,phh.signature_reference
                        ,phh.geo_latitude
                        ,phh.geo_longitude
                        ,phh.geo_date
                        ,phh.geo_signal_strength
                        ,phh.app_create_date
                        ,phh.e2e_create_date
                        ,phh.driver_comments
                        ,p.client_account
                        ,p.client_contract
                        ,p.courier_type
                        ,p.service_code
                        ,p.col_depot
                        ,p.col_tour
                        ,p.del_depot
                        ,p.del_tour
                        ,p.traffic_type
                        ,p.signature_reqd
                        ,p.nom_del_date
                        ,p.exp_del_channel
                        ,p.exp_del_tour
                        ,p.exp_del_date
                        ,p.exp_col_tour
                        ,p.exp_col_date
                        ,pad.geo_latitude del_geo_latitude
                        ,pad.geo_longitude del_geo_longitude
                        ,pad.post_code delivery_postcode
                        ,pac.post_code collection_postcode
                        ,CASE
                             WHEN phh.scan_date =
                                               (SELECT MIN (scan_date)
                                                  FROM parcel_history_holding ph
                                                 WHERE ph.parcel_id = phh.parcel_id)
                             AND pp.parcel_id IS NULL THEN 1
                             ELSE 0
                         END not_in_pp_insert_flag
                        ,get_tt_status (app_code, status_code || reason_code)
                                                                          tt_status_reason
                FROM     parcel_history_holding phh
                        ,parcel_history_pivot pp
                        ,parcels p
                        ,parcel_addresses pad
                        ,parcel_addresses pac
                   WHERE phh.parcel_id = pp.parcel_id(+)
                     AND phh.parcel_id = p.parcel_id(+)
                     AND pad.parcel_id(+) = p.parcel_id
                     AND pad.address_type(+) = 'DEL'
                     AND pac.parcel_id(+) = p.parcel_id
                     AND pac.address_type(+) = 'COL'
                   --  AND p_thread = pkg_utils.get_thread (phh.parcel_id, v_num_threads)
                     AND p.parcel_id IS NOT NULL
                ORDER BY phh.parcel_id
                        ,phh.scan_date;

    As Manik shows with the documentation link, the RULE hint was deprecated ages ago, especially with the CBO becoming the prominent optimizer in 10g.
    And as oracle no longer support Rule based optimization, you could end up with odd 'side effects' if you use it.
    Optimizer hints are something you shouldn't really be using in production code anyway...
    Comments
    Hints were introduced in Oracle7, when users had little recourse if the optimizer generated suboptimal plans. Now Oracle provides a number of tools, including the SQL Tuning Advisor, SQL plan management, and SQL Performance Analyzer, to help you address performance problems that are not solved by the optimizer. Oracle strongly recommends that you use those tools rather than hints. The tools are far superior to hints, because when used on an ongoing basis, they provide fresh solutions as your data and database environment change.
    Hints should be used sparingly, and only after you have collected statistics on the relevant tables and evaluated the optimizer plan without hints using the EXPLAIN PLAN statement. Changing database conditions as well as query performance enhancements in subsequent releases can have significant impact on how hints in your code affect performance.
    (my highlight)

  • Partitioning on Oracle 8.0.6 (rule base vs. cost base)

    At my current engagement, we are using Oracle Financials 11.0.3 on Oracle 8.0.5 which uses rule-based optimizer. However, it is been planned to upgrade the database from Oracle 8.0.5 to Oracle 8.0.6 as well as implement Oracle partitioning. With this in mind, we are concerned about possible performance issues that the implementation of partitioning may cause since RBO does not recognize it.
    We agree that the RBO will see a non-partitioned table the same as a partitioned. In this scenario where you gain the most is with backup/recoverability and general maintenance of the partitioned table.
    Nevertheless, we have a few questions:
    When implementing partitions, will the optimizer choose to go with Cost base vs. Rule base for these partitioned tables?
    Is it possible that the optimizer might get confused with this?
    If this change form RBO to CBO does occur, the application could potential perform poorly because of the way it has been written.
    Please provide any feedback.
    thanks in advance.

    If the CBO is invoked when accessing these tables, you may run into problems.
    - You'll have to analyze your tables & ensure that the statistics are kept up to date.
    - It's possible that any SQL statements which invoke the CBO rather than the RBO will have different performance characteristics. The SYSTEM data dictionary tables, for example, must use the RBO or their performance suffers dramatically. Most of the time, the CBO beats the RBO, but applications which have been heavily tuned with the RBO may have problems with the CBO.
    - Check your init.ora to see what optimizer mode you're in. If you're set to CHOOSE, the CBO will be invoked whenever statistics are available on the table(s) involved. If you choose RULE, you'll only invoke the CBO when the RBO encounters situations it doesn't have rules for.
    Justin

  • Partitioning on Oracle 8i (Rule Based vs. Cost Based)

    At my current engagement, we are using Oracle Financials 11.0.3 on Oracle 8.0.6. The application uses rule-based optimizer. The client wants to implement Oracle partitioning. With this in mind, we are concerned about possible performance issues that the implementation of partitioning may cause since RBO does not recognize it.
    We agree that the RBO will see a non-partitioned table the same as a partitioned. In this scenario where you gain the most is with backup/recoverability and general maintenance of the partitioned table.
    Nevertheless, we have a few questions:
    When implementing partitions, will the optimizer choose to go with Cost base vs. Rule base for these partitioned tables?
    Is it possible that the optimizer might get confused with this?
    Could it degrade performance at the SQL level?
    If this change from RBO to CBO does occur, the application could potential perform poorly because of the way it has been written.
    Please provide any feedback.
    Thanks in advance.

    If the CBO is invoked when accessing these tables, you may run into problems.
    - You'll have to analyze your tables & ensure that the statistics are kept up to date.
    - It's possible that any SQL statements which invoke the CBO rather than the RBO will have different performance characteristics. The SYSTEM data dictionary tables, for example, must use the RBO or their performance suffers dramatically. Most of the time, the CBO beats the RBO, but applications which have been heavily tuned with the RBO may have problems with the CBO.
    - Check your init.ora to see what optimizer mode you're in. If you're set to CHOOSE, the CBO will be invoked whenever statistics are available on the table(s) involved. If you choose RULE, you'll only invoke the CBO when the RBO encounters situations it doesn't have rules for.
    Justin

  • Table_name  +  number of records

    i need to make a listing that give me all tables that i own and beside the number of records in each table i have
    like :
    table aaa 32 records
    table bbb 962 records..
    i have large number of tables
    can anybody help?
    thank you

    - Do you need an exact count? Or an approximate count?
    - Do you use the CBO or the RBO?
    If you use the CBO and can tolerate an approximate count,
    SELECT table_name, num_rows
      FROM user_tablesOtherwise, you'd need to use dynamic SQL. This will be quite expensive, since it involves full-scanning every table in the database
    DECLARE
      l_cnt NUMBER;
    BEGIN
      FOR x IN (SELECT * FROM user_tables)
      LOOP
        EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' || x.table_name INTO l_cnt;
        dbms_output.put_line( x.table_name || ' ' || l_cnt );
      END LOOP;
    END;Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • About generating an EXPLAIN plan

    What is its use?

    Hi
    Good inputs. Hovewer explain plan is not only used by CBO but for RBO (Rule Based Optimizer), too.
    SQL> explain plan for
      2  select /*+ RULE */
      3  * 
      4  from dba_objects;
    Explained.
    SQL> select * from table (dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    | Id  | Operation                      |  Name        | Rows  | Bytes | Cost  |
    |   0 | SELECT STATEMENT               |              |       |       |       |
    |   1 |  VIEW                          | DBA_OBJECTS  |       |       |       |
    |   2 |   UNION-ALL                    |              |       |       |       |
    |*  3 |    FILTER                      |              |       |       |       |
    |   4 |     TABLE ACCESS BY INDEX ROWID| OBJ$         |       |       |       |
    |   5 |      NESTED LOOPS              |              |       |       |       |
    |   6 |       TABLE ACCESS FULL        | USER$        |       |       |       |
    |*  7 |       INDEX RANGE SCAN         | I_OBJ2       |       |       |       |
    |*  8 |     TABLE ACCESS BY INDEX ROWID| IND$         |       |       |       |
    |*  9 |      INDEX UNIQUE SCAN         | I_IND1       |       |       |       |
    |  10 |    TABLE ACCESS BY INDEX ROWID | LINK$        |       |       |       |
    |  11 |     NESTED LOOPS               |              |       |       |       |
    |  12 |      TABLE ACCESS FULL         | USER$        |       |       |       |
    |* 13 |      INDEX RANGE SCAN          | I_LINK1      |       |       |       |
    Predicate Information (identified by operation id):
       3 - filter("SYS_ALIAS_1"."TYPE#"<>1 AND "SYS_ALIAS_1"."TYPE#"<>10 OR
                  "SYS_ALIAS_1"."TYPE#"=1 AND  (SELECT 1 FROM "SYS"."IND$" "I" WHERE
                  "I"."OBJ#"=:B1 AND ("I"."TYPE#"=1 OR "I"."TYPE#"=2 OR "I"."TYPE#"=3 OR
                  "I"."TYPE#"=4 OR "I"."TYPE#"=6 OR "I"."TYPE#"=7 OR "I"."TYPE#"=9))=1)
       7 - access("SYS_ALIAS_1"."OWNER#"="U"."USER#" AND "SYS_ALIAS_1"."LINKNAME"
                  IS NULL)
           filter("SYS_ALIAS_1"."LINKNAME" IS NULL AND
                  "SYS_ALIAS_1"."NAME"<>'_default_auditing_options_' AND
                  "SYS_ALIAS_1"."NAME"<>'_NEXT_OBJECT')
       8 - filter("I"."TYPE#"=1 OR "I"."TYPE#"=2 OR "I"."TYPE#"=3 OR "I"."TYPE#"=4
                  OR "I"."TYPE#"=6 OR "I"."TYPE#"=7 OR "I"."TYPE#"=9)
       9 - access("I"."OBJ#"=:B1)
      13 - access("L"."OWNER#"="U"."USER#")
    Note: rule based optimization
    38 rows selected.
    SQL> Bye, Aron

  • Analyzing few table and customize output

    I have 20 sql scripts to analyze 20 tables, when one script done analyze i got out put and it say
    PL/SQL procedure successfully completed.
    there is any way i can modified this out to specific with each table name appeay with this output like
    PL/SQL procedure successfully completed on table_name.
    Thanks

    Are they all independent procedures? And are they materially different for each table? You might benefit by dynamically generating the anaylze commands and selecting the names from the data dictionary.
    I posted some sample code last week on this at
    Re: CBO v/s RBO advice needed

Maybe you are looking for