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)

Similar Messages

  • RULE hint and 11g

    Oracle Standard Edition 11.1.0.7.0
    We all know that the RULE hint is not longer supported, so in that case why would Oracle themselves want to use it ?
    select parsing_schema_id,sql_Text from v$sqlarea where upper(sql_text) like '%+ RULE%' or upper(sql_text) like '%+RULE%'
    I get 7 rows back from my 11gR1 database (and many more from 10gR2)
    Basically, we have a bunch of issues with parsing SQL in a 10gR2 environment, upgrading from 9iR2, setting optimizer_features_enable down at lower releases, as far as the minimum 8.0.3, does provide quicker parses with still acceptable plans, but RULE hint gives the best parse, so wondering about the support situation if we deplot it tactically. Oracle can hardly object if the RDBMS itself uses the hint, surely ?

    It was already in version 10g that the OPTIMIZER_MODE=RULE was desupported.
    "Desupported" does not mean it is no longer technically possible to use RULE nor does it mean that we do not use it anymore internally. It just means that it is no longer supported that you use this optimizer mode.
    In other words: Almost no testing was done with OPTIMIZER_MODE=RULE, and if you turn it on and you get any problems, our support will not be responsible to help you because of that setting.
    If on the other hand it turns out that for troubleshooting purpose it is necessary to go with that mode for certain statements (because our support came to that conclusion), it will be possible to use it of course without you losing further support.
    Kind regards
    Uwe
    http://uhesse.wordpress.com

  • Regarding RULE Hint Removal

    Hi ..
    We have an application having 40+ SQL's using RULE Hint. (11g R2).
    Now we have a plan to upgrade to 12c and we want to come out of these RULE Hints.
    Anyone faced similar kind of issue? what are do's and don't do's to remove RULE Hint. Please advise.
    Thank you!
    Regards
    Siva
    Edited by: 985936 on Feb 4, 2013 3:33 AM

    It looks like the /*+ RULE */ hint can still have an impact in 11.2.0.3:
    07:23:12 SQL> select * from v$version;
    BANNER
    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 Solaris: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    5 rows selected.
    Elapsed: 00:00:00.04
    07:23:20 SQL> create table test_rule_optimizer  as select * from dba_objects;
    Table created.
    Elapsed: 00:00:03.04
    07:23:23 SQL> create index TEST_RULE_OPTIMIZER_IDX on TEST_RULE_OPTIMIZER(object_type, owner, object_name);
    Index created.
    Elapsed: 00:00:01.32
    07:23:24 SQL>
    07:23:24 SQL> begin
    07:23:25   2    dbms_stats.gather_table_stats(ownname => user, tabname => 'TEST_RULE_OPTIMIZER');
    07:23:25   3  end;
    07:23:25   4  /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:03.91
    07:23:29 SQL>
    07:23:45 SQL> set autotrace on
    07:23:45 SQL> --
    07:23:45 SQL> -- Choosing these object types because they comprise over 50% of the objects in my table
    07:23:45 SQL> select count(*), max(last_ddl_time)
    07:23:45   2  from TEST_RULE_OPTIMIZER
    07:23:45   3  where object_type in ('INDEX','SYNONYM','INDEX PARTITION','LOB PARTITION');
      COUNT(*) MAX(LAST_DDL_TIME)
        136189 2013/02/04 04:17:04
    1 row selected.
    Elapsed: 00:00:00.12
    Execution Plan
    Plan hash value: 166585403
    | Id  | Operation          | Name                | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |                     |     1 |    19 |  1078   (2)| 00:00:01 |
    |   1 |  SORT AGGREGATE    |                     |     1 |    19 |            |          |
    |*  2 |   TABLE ACCESS FULL| TEST_RULE_OPTIMIZER | 19721 |   365K|  1078   (2)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter("OBJECT_TYPE"='INDEX' OR "OBJECT_TYPE"='INDEX PARTITION' OR
                  "OBJECT_TYPE"='LOB PARTITION' OR "OBJECT_TYPE"='SYNONYM')
    Statistics
              1  recursive calls
              0  db block gets
           3850  consistent gets
              0  physical reads
              0  redo size
            275  bytes sent via SQL*Net to client
            248  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    07:23:46 SQL>
    07:23:46 SQL> select /*+ rule */ count(*), max(last_ddl_time)
    07:23:46   2  from TEST_RULE_OPTIMIZER
    07:23:46   3  where object_type in ('INDEX','SYNONYM','INDEX PARTITION','LOB PARTITION');
      COUNT(*) MAX(LAST_DDL_TIME)
        136189 2013/02/04 04:17:04
    1 row selected.
    Elapsed: 00:00:00.29
    Execution Plan
    Plan hash value: 316642056
    | Id  | Operation                     | Name                    |
    |   0 | SELECT STATEMENT              |                         |
    |   1 |  SORT AGGREGATE               |                         |
    |   2 |   CONCATENATION               |                         |
    |   3 |    TABLE ACCESS BY INDEX ROWID| TEST_RULE_OPTIMIZER     |
    |*  4 |     INDEX RANGE SCAN          | TEST_RULE_OPTIMIZER_IDX |
    |   5 |    TABLE ACCESS BY INDEX ROWID| TEST_RULE_OPTIMIZER     |
    |*  6 |     INDEX RANGE SCAN          | TEST_RULE_OPTIMIZER_IDX |
    |   7 |    TABLE ACCESS BY INDEX ROWID| TEST_RULE_OPTIMIZER     |
    |*  8 |     INDEX RANGE SCAN          | TEST_RULE_OPTIMIZER_IDX |
    |   9 |    TABLE ACCESS BY INDEX ROWID| TEST_RULE_OPTIMIZER     |
    |* 10 |     INDEX RANGE SCAN          | TEST_RULE_OPTIMIZER_IDX |
    Predicate Information (identified by operation id):
       4 - access("OBJECT_TYPE"='LOB PARTITION')
       6 - access("OBJECT_TYPE"='INDEX PARTITION')
       8 - access("OBJECT_TYPE"='SYNONYM')
      10 - access("OBJECT_TYPE"='INDEX')
    Note
       - rule based optimizer used (consider using cbo)
    Statistics
              1  recursive calls
              0  db block gets
          37884  consistent gets
              3  physical reads
              0  redo size
            276  bytes sent via SQL*Net to client
            248  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    07:23:46 SQL>
    07:23:47 SQL>

  • Rule hint based query being fired by DB in AWR rpt ??

    I am looking into AWR report and i see the below sql statment being executed 58000 in 5 hour period...
    the application guy said, its not being fired from the app....is the making making some
    recursive calls or what ??? as its a pretty big amount of time that its being fired...
    and also this is a 10.2.0.3 database ....why would it use the rule hint if its being fired
    by the database ?? below is the query....
    select /*+ rule */ bucket_cnt, row_cnt, cache_cnt, null_cnt, timestamp#, sample_size,
    minimum, maximum, distcnt, lowval, hival, density, col#, spare1, spare2, avgcln from hist_head$
    where obj#=:1 and intcol#=:2

    funny thing we do have a user called DBSNMP on our database and we do not have grid control agent on it either...or even database control...then why we getting this sql ???
    $ ./emctl status agent
    EM Configuration issue. /oracle/app/product/10.2.0/xxxxxxx_nimsprod not found.

  • Replacement for 'Rule' hint in 10g

    Hi,
    We have upgraded database from 9i to 10g. We have some sql queries which are using 'RULE' hints, but 10g is not supporting 'RULE' hints, can you please suggest me any replacement hint for 'RULE' hint in 10g or alternative ways to tune the sql query so that it will work same as 9i in 10g also in performance.
    Kindly help me.
    Thanks

    Query:
    SELECT HOU.NAME EMPRESA,
    PAPF.FULL_NAME COMPRADOR,
    NVL(SUBSTR(CAEV.DE_CODE, 1, 10), ' ') DE_COMPRADOR,
    NVL(SUBSTR(CAEV.DI_CODE, 1, 10), ' ') DI_COMPRADOR,
    NVL(SUBSTR(CAEV.GG_CODE, 1, 10), ' ') GG_COMPRADOR,
    NVL(SUBSTR(CAEV.GA_CODE, 1, 10), ' ') GA_COMPRADOR,
    PH.SEGMENT1 ORDEM_COMPRA,
    PV.VENDOR_NAME FORNECEDOR,
    DECODE(PVSA.GLOBAL_ATTRIBUTE9,
    1,
    PVSA.GLOBAL_ATTRIBUTE10 || '' || PVSA.GLOBAL_ATTRIBUTE12,
    2,
    PVSA.GLOBAL_ATTRIBUTE10 || '' || PVSA.GLOBAL_ATTRIBUTE11 || '' ||
    PVSA.GLOBAL_ATTRIBUTE12,
    3,
    LPAD(PV.SEGMENT1 || REPLACE(PVSA.VENDOR_SITE_CODE, '-', ''),
    15,
    '0'),
    PVSA.GLOBAL_ATTRIBUTE10 || '' || PVSA.GLOBAL_ATTRIBUTE11 || '' ||
    PVSA.GLOBAL_ATTRIBUTE12) CNPJ,
    PVSA.VENDOR_SITE_CODE LOCAL,
    REPLACE(REPLACE(REPLACE(REPLACE(PH.COMMENTS, CHR(13) || CHR(10) || CHR(9), ' '),
    CHR(9), ' '), CHR(10), ' '), '#', '')
    DESCRIÇÃO,
    (SELECT LAST_NAME
    FROM APPS.PER_PEOPLE_F
    WHERE EMPLOYEE_NUMBER = PH.ATTRIBUTE1
    AND EFFECTIVE_END_DATE >= SYSDATE) GESTOR_DO_CONTRATO,
    NVL(SUBSTR(CAEV2.DE_CODE, 1, 10), ' ') DE_GESTOR,
    NVL(SUBSTR(CAEV2.DI_CODE, 1, 10), ' ') DI_GESTOR,
    NVL(SUBSTR(CAEV2.GG_CODE, 1, 10), ' ') GG_GESTOR,
    NVL(SUBSTR(CAEV2.GA_CODE, 1, 10), ' ') GA_GESTOR,
    NVL(CAEV2.GA_NOME, ' ') GA_NOME,
    PDT.TYPE_NAME TIPO,
    TO_CHAR(PH.START_DATE, 'DD/MM/YYYY') DATA_INICIAL_EFETIVAÇÃO,
    TO_CHAR(PH.END_DATE, 'DD/MM/YYYY') DATA_FINAL_EFETIVAÇÃO,
    NVL(PH.CLOSED_CODE, 'OPEN') STATUS_DO_FECHAMENTO,
    PH.BLANKET_TOTAL_AMOUNT VALOR_DO_CONTRATO,
    (SELECT EMAIL_ADDRESS
    FROM APPS.PER_PEOPLE_F
    WHERE EMPLOYEE_NUMBER = PH.ATTRIBUTE1
    AND EFFECTIVE_END_DATE >= SYSDATE) EMAIL_GESTOR_DO_CONTRATO
    ,FLV.MEANING STATUS_DA_APROVAÇÃO
    ,NVL((SELECT MCB.SEGMENT1 || '.' ||
    MCB.SEGMENT2 || '.' ||
    MCB.SEGMENT3 || '.' ||
    MCB.SEGMENT4 || '.' ||
    MCB.SEGMENT5
    FROM PO.PO_HEADERS_ALL PAI,
    PO.PO_HEADERS_ALL FILHO,
    PO.PO_LINES_ALL PLA,
    INV.MTL_CATEGORIES_B MCB
    WHERE MCB.CATEGORY_ID = PLA.CATEGORY_ID
    AND PAI.TYPE_LOOKUP_CODE = 'CONTRACT'
    AND PLA.CONTRACT_ID = PAI.PO_HEADER_ID
    AND PLA.PO_HEADER_ID = FILHO.PO_HEADER_ID
    AND PAI.PO_HEADER_ID = PH.PO_HEADER_ID
    AND NVL(PLA.CANCEL_FLAG, 'N') = 'N'
    AND MCB.SEGMENT1 = 'SV'
    AND ROWNUM = 1) ,
    (SELECT MCB.SEGMENT1 || '.' ||
    MCB.SEGMENT2 || '.' ||
    MCB.SEGMENT3 || '.' ||
    MCB.SEGMENT4 || '.' ||
    MCB.SEGMENT5
    FROM PO.PO_HEADERS_ALL PAI,
    PO.PO_HEADERS_ALL FILHO,
    PO.PO_LINES_ALL PLA,
    INV.MTL_CATEGORIES_B MCB
    WHERE MCB.CATEGORY_ID = PLA.CATEGORY_ID
    AND PAI.TYPE_LOOKUP_CODE = 'CONTRACT'
    AND PLA.CONTRACT_ID = PAI.PO_HEADER_ID
    AND PLA.PO_HEADER_ID = FILHO.PO_HEADER_ID
    AND PAI.PO_HEADER_ID = PH.PO_HEADER_ID
    AND NVL(PLA.CANCEL_FLAG, 'N') = 'N'
    AND MCB.SEGMENT1 = 'SE'
    AND ROWNUM = 1)) CATEGORIA,
    PH.ATTRIBUTE2 TIPO_DE_CONTRATO
    FROM ---
    (SELECT DISTINCT
    PAPF.PERSON_ID,
    PAPF.EMPLOYEE_NUMBER,
    PAPF.FULL_NAME,
    PAPF.EMAIL_ADDRESS,
    HAOU_GA.ATTRIBUTE10 GA_CODE,
    HAOU_GA.ATTRIBUTE11 GA_NOME,
    HAOU_GG.ATTRIBUTE10 GG_CODE,
    HAOU_GG.ATTRIBUTE11 GG_NOME,
    HAOU_DI.ATTRIBUTE10 DI_CODE,
    HAOU_DI.ATTRIBUTE11 DI_NOME,
    HAOU_DE.ATTRIBUTE10 DE_CODE,
    HAOU_DE.ATTRIBUTE11 DE_NOME
    FROM APPS.PER_ALL_PEOPLE_F PAPF,
    APPS.PER_ALL_ASSIGNMENTS_F PAAP,
    APPS.PER_ALL_POSITIONS PAP,
    APPS.HR_ALL_ORGANIZATION_UNITS HAOU_GA,
    APPS.HR_ALL_ORGANIZATION_UNITS HAOU_GG,
    APPS.HR_ALL_ORGANIZATION_UNITS HAOU_DI,
    APPS.HR_ALL_ORGANIZATION_UNITS HAOU_DE
    WHERE PAPF.PERSON_ID = PAAP.PERSON_ID
    AND PAAP.POSITION_ID = PAP.POSITION_ID(+)
    AND PAPF.EFFECTIVE_END_DATE = TO_DATE('31/12/4712', 'DD/MM/YYYY')
    AND PAAP.EFFECTIVE_END_DATE = TO_DATE('31/12/4712', 'DD/MM/YYYY')
    AND SUBSTR(PAP.NAME, 1, 12) = HAOU_GA.ATTRIBUTE9 (+)
    AND SUBSTR(PAP.NAME, 1, 10) = HAOU_GG.ATTRIBUTE9 (+)
    AND SUBSTR(PAP.NAME, 1, 8) = HAOU_DI.ATTRIBUTE9 (+)
    AND SUBSTR(PAP.NAME, 1, 6) = HAOU_DE.ATTRIBUTE9 (+)) CAEV2,
    APPS.PO_VENDORS PV,
    APPS.PO_VENDOR_SITES_ALL PVSA,
    APPS.PER_ALL_PEOPLE_F PAPF,
    APPS.PO_DOCUMENT_TYPES_ALL_TL PDT,
    APPS.HR_ALL_ORGANIZATION_UNITS HOU,
    (SELECT DISTINCT
    PAPF.PERSON_ID,
    PAPF.EMPLOYEE_NUMBER,
    PAPF.FULL_NAME,
    PAPF.EMAIL_ADDRESS,
    HAOU_GA.ATTRIBUTE10 GA_CODE,
    HAOU_GA.ATTRIBUTE11 GA_NOME,
    HAOU_GG.ATTRIBUTE10 GG_CODE,
    HAOU_GG.ATTRIBUTE11 GG_NOME,
    HAOU_DI.ATTRIBUTE10 DI_CODE,
    HAOU_DI.ATTRIBUTE11 DI_NOME,
    HAOU_DE.ATTRIBUTE10 DE_CODE,
    HAOU_DE.ATTRIBUTE11 DE_NOME
    FROM APPS.PER_ALL_PEOPLE_F PAPF,
    APPS.PER_ALL_ASSIGNMENTS_F PAAP,
    APPS.PER_ALL_POSITIONS PAP,
    APPS.HR_ALL_ORGANIZATION_UNITS HAOU_GA,
    APPS.HR_ALL_ORGANIZATION_UNITS HAOU_GG,
    APPS.HR_ALL_ORGANIZATION_UNITS HAOU_DI,
    APPS.HR_ALL_ORGANIZATION_UNITS HAOU_DE
    WHERE PAPF.PERSON_ID = PAAP.PERSON_ID
    AND PAAP.POSITION_ID = PAP.POSITION_ID(+)
    AND PAPF.EFFECTIVE_END_DATE = TO_DATE('31/12/4712', 'DD/MM/YYYY')
    AND PAAP.EFFECTIVE_END_DATE = TO_DATE('31/12/4712', 'DD/MM/YYYY')
    AND SUBSTR(PAP.NAME, 1, 12) = HAOU_GA.ATTRIBUTE9 (+)
    AND SUBSTR(PAP.NAME, 1, 10) = HAOU_GG.ATTRIBUTE9 (+)
    AND SUBSTR(PAP.NAME, 1, 8) = HAOU_DI.ATTRIBUTE9 (+)
    AND SUBSTR(PAP.NAME, 1, 6) = HAOU_DE.ATTRIBUTE9 (+)) CAEV,
    APPS.PO_HEADERS_ALL PH,
    APPS.FND_LOOKUP_VALUES FLV
    WHERE PV.VENDOR_ID(+) = PH.VENDOR_ID
    AND PVSA.VENDOR_ID(+) = PH.VENDOR_ID
    AND PVSA.VENDOR_SITE_ID(+) = PH.VENDOR_SITE_ID
    AND PVSA.GLOBAL_ATTRIBUTE9 <> 1
    AND PAPF.EFFECTIVE_END_DATE > SYSDATE
    AND PAPF.PERSON_ID(+) = PH.AGENT_ID
    AND PH.AGENT_ID = CAEV.PERSON_ID(+)
    AND PH.ATTRIBUTE1 = CAEV2.EMPLOYEE_NUMBER(+)
    AND PDT.LANGUAGE = 'PTB'
    AND PDT.ORG_ID(+) = PH.ORG_ID
    AND PDT.DOCUMENT_TYPE_CODE IN ('PO', 'PA')
    AND PDT.DOCUMENT_SUBTYPE(+) = PH.TYPE_LOOKUP_CODE
    AND HOU.ORGANIZATION_ID(+) = PH.ORG_ID
    AND PH.ORG_ID                       IN (90, 91, 92, 93, 94, 410, 414, 19626, 19628, 137) CVRD, HISPANOBRAS, KOBRASCO, NIBRASCO, ITABRASCO,CPBS,FGC,FCA,SALOBO,FVRD
    AND PH.ORG_ID                      IN (90,19626) CVRD,FCA
    AND NVL(PH.FROZEN_FLAG, 'N') = 'N'
    AND NVL(PH.CANCEL_FLAG, 'N') = 'N'
    AND NVL(PH.AUTHORIZATION_STATUS, 'INCOMPLETE') IN ('APPROVED', 'PRE-APPROVED', 'IN PROCESS', 'REQUIRES REAPPROVAL')
    AND PH.TYPE_LOOKUP_CODE = 'CONTRACT'
    AND EXISTS (SELECT 1
    FROM PO.PO_HEADERS_ALL PAI,
    PO.PO_HEADERS_ALL FILHO,
    PO.PO_LINES_ALL PLA,
    INV.MTL_CATEGORIES_B MCB
    WHERE MCB.CATEGORY_ID = PLA.CATEGORY_ID
    AND PAI.TYPE_LOOKUP_CODE = 'CONTRACT'
    AND PLA.CONTRACT_ID = PAI.PO_HEADER_ID
    AND PLA.PO_HEADER_ID = FILHO.PO_HEADER_ID
    AND PAI.PO_HEADER_ID = PH.PO_HEADER_ID
    AND NVL(PLA.CANCEL_FLAG, 'N') = 'N'
    AND MCB.SEGMENT1 IN ('SE', 'SV'))
    -- AND PH.ATTRIBUTE2 IN ('CUSTEIO (SERVIÇO)', 'INVESTIMENTO (SERVIÇO)')
    AND ((NVL(PH.CLOSED_CODE, 'OPEN') = 'OPEN') OR
    (NVL(PH.CLOSED_CODE, 'OPEN') = 'CLOSED' AND
    PH.END_DATE BETWEEN TO_DATE(:DATA_INICIO||' 00:00:00', 'DD/MM/YYYY HH24:MI:SS') AND
    TO_DATE(:DATA_FIM||' 23:59:59', 'DD/MM/YYYY HH24:MI:SS')))
    and flv.language = 'PTB'
    and flv.lookup_type = 'AUTHORIZATION STATUS'
    and flv.lookup_code = nvl(ph.authorization_status,'INCOMPLETE')

  • Does RULE hint cause ORA-01555 errors ?

    DB Version:9.2.0.5.0
    OS:SunOS 5.9
    Our DBA is saying that the RULE hint in the below SQL might be causing ORA-01555 error. Is it true? Does RULE hint cause ORA-01555 errors
    SELECT /*+ RULE */  COUNT(*)
      FROM ( SELECT /*+ RULE */  DISTINCT CAR_HDR.CAR_NBR AS A1, CAR_HDR.PLT_ID AS A29,
      CAR_HDR.PKT_CTRL_NBR AS A2, CAR_HDR.TOTAL_QTY AS A21, CAR_HDR.STAT_CODE AS A6,
      CAR_HDR.CURR_LOCN_ID AS A12,
      CAR_HDR.CAR_NBR  AS A145,
      CAR_HDR.WN_NBR AS A4, CAR_HDR.PCALL_NBR AS A7, CAR_HDR.CHAIN_CNT AS A119,
      CAR_HDR.SHPMT_NBR AS A35, LPN_HDR.WHSE AS A105, CAR_HDR.MISC_CAR AS A146, ''  AS A138,
      CAR_HDR.CHUTE_ID AS A132, CAR_HDR.MOD_DATE_TIME AS A82, LPN_HDR.LOCN_CLASS AS A106,
      LPN_HDR.AREA AS A107, LPN_HDR.ZONE AS A108, LPN_HDR.AISLE AS A109, LPN_HDR.BAY AS A110,
      LPN_HDR.LVL AS A111, LPN_HDR.POSN AS A112
          FROM INV_MASTER , CAR_DTL , LPN_HDR , CAR_HDR 
           WHERE CAR_HDR.CAR_NBR=CAR_DTL.CAR_NBR(+)
           AND CAR_HDR.CURR_LOCN_ID=LPN_HDR.LOCN_ID(+)
           AND CAR_HDR.WHSE=LPN_HDR.WHSE(+)
           AND CAR_DTL.SKU_ID=INV_MASTER.SKU_ID(+)
           AND CAR_HDR.CT_SEQ = 'ALB10'
           AND INV_MASTER.INV_CODE = 98
           AND INV_MASTER.TRACK_CODE = 'P10' )
          

    user636669 wrote:
    DB Version:9.2.0.5.0
    OS:SunOS 5.9
    Our DBA is saying that the RULE hint in the below SQL might be causing ORA-01555 error. Is it true? Does RULE hint cause ORA-01555 errorsThe full statement is causing the ORA-01555 error. Each line of the statement is important therefore each line is reponsible for the error. I personally think the DISTINCT keyword has a bigger influence than the RULE hint.
    I suggest to check what you want to do with that count result. maybe there are better ways to get the same result. Maybe you can even ignore the distinct keyword or remove some outer joins. Using the CBO might result in the same plan as using the RBO, so you you will never know if that removing the hint will help or if if you'll get the same problem later again.

  • How to specify rule hints in exp parfile query

    Dear All,
    How can I use EXP utility to export tha data whose query is following:
    select /*+ INDEX(partlist, IDX_PSER)*/ item_number from partlist where class = 'C' ;
    In my exp parfile i have the QUERY parameter that allows me to specify the where clause as follows:
    where class = 'C' ;
    However my concern is the hints rule part, which is autogenerated by exp. How can i specify the select hint(/*+ xxxx */
    Pls advice.
    Thanks,
    Mahesh

    Hi,
    In that case temporary create the table from the user which does not have tablespace resource issues. If all the user has tablespace issue, then I doubt you have any option except to use query clause in actual table.
    Why you feel index hint would be more useful then full table scan in exp? i.e. records to be exported is very small(nearly 2 to 3%) compared to total records
    Regards
    Anurag Tibrewal.

  • Force statement to use a given rule or execution plan

    Hi!
    We have a statement that in our production system takes 6-7 seconds to complete. The statement comes from our enterprise application's core code and we are not able to change the statement.
    When using a RULE-hint (SELECT /*+RULE*/ 0 pay_rec...........) for this statement, the execution time is down to 500 milliseconds.
    My question is: Is there any way to pin a execution plan to a given statement. I have started reading about outlines, which seems promising. However, the statement is not using bind-variables, and since this is core code in an enterprise application I cannot change that either. Is it possible to use outlines with such a statement?
    Additional information:
    When I remove all statistics for the involved tables, the query blows away in 500 ms.
    The table tran_info_types has 61 rows and is a stable table with few updates
    The table ab_tran_info has 1 717 439 records and is 62 MB in size.
    The table query_result has 777 015 records and is 216 MB in size. This table is constantly updated/insterted/deleted.
    The query below return 0 records as there is no hits in the table query_result.
    This is the statement:
    SELECT  /*+ALL_ROWS*/
           0 pay_rec, abi.tran_num, abi.type_id, abi.VALUE
      FROM ab_tran_info abi,
           tran_info_types ti,
           query_result qr1,
           query_result qr2
    WHERE abi.tran_num = qr1.query_result
       AND abi.type_id = qr2.query_result
       AND abi.type_id = ti.type_id
       AND ti.ins_or_tran = 0
       AND qr1.unique_id = 5334549
       AND qr2.unique_id = 5334550
    UNION ALL
    SELECT 1 pay_rec, abi.tran_num, abi.type_id, abi.VALUE
      FROM ab_tran_info abi,
           tran_info_types ti,
           query_result qr1,
           query_result qr2
    WHERE abi.tran_num = qr1.query_result
       AND abi.type_id = qr2.query_result
       AND abi.type_id = ti.type_id
       AND ti.ins_or_tran = 0
       AND qr1.unique_id = 5334551
       AND qr2.unique_id = 5334552;Here is the explain plan with statistics:
    Plan
    SELECT STATEMENT  HINT: ALL_ROWSCost: 900  Bytes: 82  Cardinality: 2                           
         15 UNION-ALL                      
              7 NESTED LOOPS  Cost: 450  Bytes: 41  Cardinality: 1                 
                   5 NESTED LOOPS  Cost: 449  Bytes: 1,787,940  Cardinality: 59,598            
                        3 NESTED LOOPS  Cost: 448  Bytes: 19,514,824  Cardinality: 1,027,096       
                             1 INDEX RANGE SCAN UNIQUE TRADEDB.TIT_DANIEL_2 Search Columns: 1  Cost: 1  Bytes: 155  Cardinality: 31 
                             2 INDEX RANGE SCAN UNIQUE TRADEDB.ATI_DANIEL_7 Search Columns: 1  Cost: 48  Bytes: 471,450  Cardinality: 33,675 
                        4 INDEX UNIQUE SCAN UNIQUE TRADEDB.QUERY_RESULT_INDEX Search Columns: 2  Bytes: 11  Cardinality: 1       
                   6 INDEX UNIQUE SCAN UNIQUE TRADEDB.QUERY_RESULT_INDEX Search Columns: 2  Bytes: 11  Cardinality: 1            
              14 NESTED LOOPS  Cost: 450  Bytes: 41  Cardinality: 1                 
                   12 NESTED LOOPS  Cost: 449  Bytes: 1,787,940  Cardinality: 59,598            
                        10 NESTED LOOPS  Cost: 448  Bytes: 19,514,824  Cardinality: 1,027,096       
                             8 INDEX RANGE SCAN UNIQUE TRADEDB.TIT_DANIEL_2 Search Columns: 1  Cost: 1  Bytes: 155  Cardinality: 31 
                             9 INDEX RANGE SCAN UNIQUE TRADEDB.ATI_DANIEL_7 Search Columns: 1  Cost: 48  Bytes: 471,450  Cardinality: 33,675 
                        11 INDEX UNIQUE SCAN UNIQUE TRADEDB.QUERY_RESULT_INDEX Search Columns: 2  Bytes: 11  Cardinality: 1       
                   13 INDEX UNIQUE SCAN UNIQUE TRADEDB.QUERY_RESULT_INDEX Search Columns: 2  Bytes: 11  Cardinality: 1            Here is the execution plan when I have removed all statistics (exec DBMS_STATS.DELETE_TABLE_STATS(.........,..........); )
    Plan
    SELECT STATEMENT  HINT: ALL_ROWSCost: 12  Bytes: 3,728  Cardinality: 16                           
         15 UNION-ALL                      
              7 NESTED LOOPS  Cost: 6  Bytes: 1,864  Cardinality: 8                 
                   5 NESTED LOOPS  Cost: 6  Bytes: 45,540  Cardinality: 220            
                        3 NESTED LOOPS  Cost: 6  Bytes: 1,145,187  Cardinality: 6,327       
                             1 TABLE ACCESS FULL TRADEDB.TRAN_INFO_TYPES Cost: 2  Bytes: 104  Cardinality: 4 
                             2 INDEX RANGE SCAN UNIQUE TRADEDB.ATI_DANIEL_6 Search Columns: 1  Cost: 1  Bytes: 239,785  Cardinality: 1,547 
                        4 INDEX UNIQUE SCAN UNIQUE TRADEDB.QUERY_RESULT_INDEX Search Columns: 2  Bytes: 26  Cardinality: 1       
                   6 INDEX UNIQUE SCAN UNIQUE TRADEDB.QUERY_RESULT_INDEX Search Columns: 2  Bytes: 26  Cardinality: 1            
              14 NESTED LOOPS  Cost: 6  Bytes: 1,864  Cardinality: 8                 
                   12 NESTED LOOPS  Cost: 6  Bytes: 45,540  Cardinality: 220            
                        10 NESTED LOOPS  Cost: 6  Bytes: 1,145,187  Cardinality: 6,327       
                             8 TABLE ACCESS FULL TRADEDB.TRAN_INFO_TYPES Cost: 2  Bytes: 104  Cardinality: 4 
                             9 INDEX RANGE SCAN UNIQUE TRADEDB.ATI_DANIEL_6 Search Columns: 1  Cost: 1  Bytes: 239,785  Cardinality: 1,547 
                        11 INDEX UNIQUE SCAN UNIQUE TRADEDB.QUERY_RESULT_INDEX Search Columns: 2  Bytes: 26  Cardinality: 1       
                   13 INDEX UNIQUE SCAN UNIQUE TRADEDB.QUERY_RESULT_INDEX Search Columns: 2  Bytes: 26  Cardinality: 1            Our Oracle 9.2 database is set up with ALL_ROWS.
    Outlines: http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96533/outlines.htm#13091
    Cursor sharing: http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3696883368520

    Hi!
    We are on Oracle 9iR2, running on 64-bit Linux.
    We are going to upgrade to Oracle 10gR2 in some months. Oracle 11g is not an option for us as our application is not certified by our vendor to run on that version.
    However, our performance problems are urgent so we are looking for a solution before we upgrade as we are not able to upgrade before we have done extensive testing which takes 2-3 months.
    We have more problem sql's than the one shown in this post. I am using the above SQL as a sample as I think we can solve many other slow running SQL's if we solve this one.
    Is the SQL Plan management an option on Oracle 9i and/or Oracle 10g?

  • Oracle 11g with OPTIMIZER_MODE=RULE go faster!!

    I recently migrated Oracle 9.2.0.8 to Oracle 11g but the querys doesn't work as I hope.
    The same query takes 3:20 min aprox using optimizer_mode=ALL_ROWS and 0:20 using optimizer_mode=RULE or using RULE hint.
    The query in CBO makes a cartesian product between the indexes of the table.
    This is one query and the "autrotrace on" log on Oracle 11g:
    SELECT /*+ NO_INDEX (PK0004111303310) */MIN(BASE.ID_SCHED_TASK)+1 I
    FROM M4RJS_SCHED_TASKS BASE
    WHERE NOT EXISTS
    (SELECT BASE2.ID_SCHED_TASK
    FROM M4RJS_SCHED_TASKS BASE2
    WHERE BASE2.ID_SCHED_TASK>BASE.ID_SCHED_TASK
    AND BASE2.ID_SCHED_TASK<BASE.ID_SCHED_TASK+2)
    ORDER BY 1 ASC
    Execution Plan
    Plan hash value: 3937517195
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 14 | | 328 (2)| 00:00:04 |
    | 1 | SORT AGGREGATE | | 1 | 14 | | | |
    | 2 | MERGE JOIN ANTI | | 495 | 6930 | | 328 (2)| 00:00:04 |
    | 3 | INDEX FULL SCAN | PK0004111303310 | 49487 | 338K| | 119 (1)| 00:00:02 |
    |* 4 | FILTER | | | | | | |
    |* 5 | SORT JOIN | | 49487 | 338K| 1576K| 209 (2)| 00:00:03 |
    | 6 | INDEX FAST FULL SCAN| PK0004111303310 | 49487 | 338K| | 33 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    4 - filter("BASE2"."ID_SCHED_TASK"<"BASE"."ID_SCHED_TASK"+2)
    5 - access("BASE2"."ID_SCHED_TASK">"BASE"."ID_SCHED_TASK")
    filter("BASE2"."ID_SCHED_TASK">"BASE"."ID_SCHED_TASK")
    Statistics
    1 recursive calls
    0 db block gets
    242 consistent gets
    8 physical reads
    0 redo size
    519 bytes sent via SQL*Net to client
    524 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    1 rows processed
    Thanks to all !

    Sorry Mschnatt, I posted the wrong query, i was testing with HINTS, the correct query is your posted query.
    1* I analyzed the tables and the result is the same:
    This is the query and "autorace on" log using OPTIMIZER_MODE=RULE on Oracle 11g:
    SQL> R
    1 SELECT MIN(BASE.ID_SCHED_TASK)+1 I
    2 FROM M4RJS_SCHED_TASKS BASE
    3 WHERE NOT EXISTS
    4 (SELECT BASE2.ID_SCHED_TASK
    5 FROM M4RJS_SCHED_TASKS BASE2
    6 WHERE BASE2.ID_SCHED_TASK>BASE.ID_SCHED_TASK
    7 AND BASE2.ID_SCHED_TASK<BASE.ID_SCHED_TASK+2)
    8* ORDER BY 1 ASC
    I
    2
    Elapsed: 00:00:00.33
    Execution Plan
    Plan hash value: 795265574
    | Id | Operation | Name |
    | 0 | SELECT STATEMENT | |
    | 1 | SORT AGGREGATE | |
    |* 2 | FILTER | |
    | 3 | TABLE ACCESS FULL | M4RJS_SCHED_TASKS |
    |* 4 | INDEX RANGE SCAN | PK0004111303310 |
    Predicate Information (identified by operation id):
    2 - filter( NOT EXISTS (SELECT 0 FROM "M4RJS_SCHED_TASKS" "BASE2"
    WHERE "BASE2"."ID_SCHED_TASK"<:B1+2 AND "BASE2"."ID_SCHED_TASK">:B2))
    4 - access("BASE2"."ID_SCHED_TASK">:B1 AND
    "BASE2"."ID_SCHED_TASK"<:B2+2)
    Note
    - rule based optimizer used (consider using cbo)
    Statistics
    0 recursive calls
    0 db block gets
    101509 consistent gets
    0 physical reads
    0 redo size
    519 bytes sent via SQL*Net to client
    524 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    1 rows processed
    This is the query and "autorace on" log using OPTIMIZER_MODE=ALL_ROWA on Oracle 11g:
    Elapsed: 00:03:14.78
    Execution Plan
    Plan hash value: 3937517195
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 12 | | 317 (2)| 00:00:04 |
    | 1 | SORT AGGREGATE | | 1 | 12 | | | |
    | 2 | MERGE JOIN ANTI | | 495 | 5940 | | 317 (2)| 00:00:04 |
    | 3 | INDEX FULL SCAN | PK0004111303310 | 49487 | 289K| | 119 (1)| 00:00:02 |
    |* 4 | FILTER | | | | | | |
    |* 5 | SORT JOIN | | 49487 | 289K| 1176K| 198 (3)| 00:00:03 |
    | 6 | INDEX FAST FULL SCAN| PK0004111303310 | 49487 | 289K| | 33 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    4 - filter("BASE2"."ID_SCHED_TASK"<"BASE"."ID_SCHED_TASK"+2)
    5 - access("BASE2"."ID_SCHED_TASK">"BASE"."ID_SCHED_TASK")
    filter("BASE2"."ID_SCHED_TASK">"BASE"."ID_SCHED_TASK")
    Statistics
    0 recursive calls
    0 db block gets
    242 consistent gets
    0 physical reads
    0 redo size
    519 bytes sent via SQL*Net to client
    524 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    1 rows processed
    3* This is an example query, the problem persist in other bigger queries.
    Thanks for you help

  • Passing Hints Using JDBC

    We are experiencing a problem w/ a query we are passing into Oracle 9i using Hibernate. The query returns quickly ( a few seconds) if you run it in SQL Plus (it only needs to return a few hundred rows) but hangs if it is passed through the JDBC connection. The developers wrote the query using the /*Rule*/ hint which is now deprecated. If you remove the hing in SQL Plus, it suddenly takes several minutes to return. Is the JDBC driver (which uses OCI I believe) be stripping out the hint before it passes it to the database because it's deprecated?

    It's very common that different sessions have different execution plans for the query of the same text.
    1. As pointed out in the previous reply, check out the execution plan of both queries and post the results if you need help in analyze the result.
    2. Check if the JDBC session has modified parameters and/or diagnostic events.
    http://dioncho.wordpress.com/2009/07/18/spying-on-the-other-session/
    ==================================
    Dion Cho - Oracle Performance Storyteller
    http://dioncho.wordpress.com (english)
    http://ukja.tistory.com (korean)
    http://dioncho.blogspot.com (japanese)
    ==================================

  • Rule base optimizer in 9i and 10g

    Hi
    All,
    I just upgraded databses from oracle 9.2.0.6 to 10.2.0.3.
    I think as i know oracle 10g no more support rule based optimzer ( correct me if i am wrong)
    but some of the script have rule optimizer hint over there. If i keep as it is will it give me error or I need to change something.
    Thanks,
    Vishal

    what should i do? should i keep as it is?
    RBO is obsoleted in 10g , but hint RULE still work i.e it will not error out.
    Check execution plan with and without hint , if execution plan look better without hint,
    go for it. Keeping as it is , will not harm , but data increase/change drastically in underlying table of query , in that case CBO might give you better execution plan then with rule hint.

  • RULE BASED OPTIMIZER

    hi,
    my database is 10.2.0.1...by default optimizer_mode=ALL_ROWS..
    for some sessions..i need rule based optimizer...
    so can i use
    alter session set optimizer_mode=rule;
    will it effect that session only or entire database....
    and following also.i want to make them at session level...
    ALTER SESSION SET "_HASH_JOIN_ENABLED" = FALSE;
    ALTER SESSION SET "_OPTIMIZER_SORTMERGE_JOIN_ENABLED" = FALSE ;
    ALTER SESSION SET "_OPTIMIZER_JOIN_SEL_SANITY_CHECK" = TRUE;
    will those effect only session or entire database...please suggest

    < CBO outperforms RBO ALWAYS! > I disagree - mildlyWhen I tune SQL, the first thing I try is a RULE hint, and in very simple databases, the RBO still does a good job.
    Of course, you should not use RULE hints in production (That's Oracle job).
    When Oracle eBusiness suite migrated to the CBO, they placed gobs of RULE hints into their own SQL!!
    Anyway, always adjust your CBO stats to replicate an RBO execution plan . . . .
    specifically CAST() conversions from collections and pipelined functions.Interesting. Hsve you tried dynamic sampling for that?
    Hope this helps. . .
    Don Burleson
    Oracle Press author
    Author of “Oracle Tuning: The Definitive Reference”
    http://www.dba-oracle.com/bp/s_oracle_tuning_book.htm

  • Rule Based Optimization

    Hi,
    Rule Based Optimization is a deprecated feature in Oracle 10g.We are in the process of migrating from Oracle 9i to 10g.I have never heard of this Rule based Optimization earlier.I have googled for the same.But, got confused with the results.
    Can anybody shed some light on the below things...
    Is this Optimization done by Oracle or as a developer do we need to take care of the rules while writing SQL statements?
    There is another thing called Cost Based Optimization...
    Who will instruct the Oracle whether to use Rule Based Optimization or cost Based Optimization?
    Thanks & Regards,
    user569598

    Hope the following explanation would be helpful.
    Whenever a statement is fired, Oracle should goes through the following stages:
    Parse -> Execute -> Fetch (fetch only for select statement).
    During Parse, Oracle first evaluates, Syntatic checking (SELECT, FROM, WHERE, ORDER BY ,GROUP and etc) and then Semantic Checking (columns names, table name, user permission on the objects and etc). Once these two stages passes, then, it has to decided whether to do soft parse or hard parse. If similar cursor(statement) doesn't exits in the shared pool, Oracle goes for Hard parse where Optimizer comes in picture for generating query plan.
    Oracle has to decide either RBO or CBO. It also depends on the OPTIMIZER_MODE parameter value. If RULE hint is used, RBO will be used, if there are no statistics for those tables involved in the query, Oracle decides RBO, (condition applies). If statistics are available, or dynamic samplying is defined then Oracle use CBO to prepare the Optimal execution plan.
    RBO is simply relies on set of rules where CBO relies on statistical information.
    Jaffar

  • Index usage making SQL slower.

    Hello,
    While working on a performance tuning activity on Oracle 10.2.0.4 on Solaris 10, I encountered a problem wherein one of our DBA's suggested indexing 2 columns of a certain table. One of the queries which is being run on that table has a RULE hint, and it is seen to be making use of this newly created index. Before the index was created, this query was running fine and getting completed within 30 mins or so. However after the index is created, it is now taking 12 hours on average to complete. Please note that in both the above cases, the CURSOR_SHARING parameter was set to EXACT. Yes, after the index was created its statistics were computed, and for both the index and the base table statistics were gathered. The query is making use of bind variables and is being run via the SQR engine of PeopleSoft.
    Please advice what can be the possible reasons for such delays being caused?
    For any information, please let me know and I would provide the same in this forum/
    Note for moderators: I could not find the section for Performance tuning, so I am asking this question in the general forum. Apologies.
    Thank You,
    Prashant.

    Index scans are not always faster.
    Full table scans are not always bad.
    I doubt that the RULE hint is necessary.
    In general, [url http://www.centrexcc.com/Tuning%20by%20Cardinality%20Feedback.pdf]the CBO does an excellent job of finding the best access plan for a given sql provided it is able to accurately estimate the cardinalities of the row sources in the plan.
    See advice and information required in the template tuning threads:
    [url https://forums.oracle.com/forums/thread.jspa?threadID=863295]How to post a sql tuning request
    [url https://forums.oracle.com/forums/thread.jspa?messageID=1812597]When your query takes too long

  • Deductions Report performance issue

    Has anyone encountered performance problems lately with the Deductions Report?
    We have a custom report that is a modified version of the seeded report, and we cannot run the report to completion since our last round of patching. Patches applied are listed below, and include YE Phase 2.
    We have not yet opened a TAR on this, because we'll need to gather some information internally first.
    Thanks,
    Carrie
    Year-end and year-start updates, as follows:
    Patches 5555555, 5555550, 5650846, and HR Global – 2006 Oracle Year-End Phase 2
    Patch 5573903 – Quantum 2.8.2, Quantum 2006 Upgrade
    Patches 5589335 (prerequisite) and 5511810 – EEO Patch
    Patch 5416623 – Unable to process Admin Life Events (Benefits)
    Carrie Hollack
    [email protected]

    We've hit the performance bug and logged an SR. We ran the shipped report and it chugged for 2 1/2 days then blew up on snapshot too old. If you can avoid that error then it fails with ORA-01722: invalid number. I defragged and analyzed the Payroll tables and indexes but it's not enough to help the bad code. I think part of the issue is that the report code just uses a generic /*+ RULE */ hint. Another part of the issue may be that NULLs in the payroll tables aren't properly accounted for in the code.
    The behavior of the 'RULE' hint seems to be dependent on what the Paryoll LOW_VOLUME parameter is set to. That is, with LOW_VOLUME=Y and small tables the 'RULE' hint might be fine, but in the real World with with LOW_VOLUME=YouGottaBeKidding it doesn't.
    The new Payroll Activity Report for the whole year has very good performance--it only took 4 hours in our environment--and it used to take days.
    Open an SR and ask to be attached to Bug 5742521.

Maybe you are looking for

  • How do I keep layers from auto-expanding in the Layers Palette?

    Hello all. I'm working on a rather complex piece of artwork in Illustrator CC with the latest Mac OS, with several objects on each layer. Whenever I click an object, its layer in the Layers palette auto-expands, pushing all of the main layers off of

  • Why won't my FireWire Solo work with the Mavericks OS?

    I have recently upgraded to the Mavericks OS (10.9.2) and now my FireWire Solo is not even recognized when I plug it in. Are the M-Audio products no longer compatible with the Mavericks OS? Somebody please help me out! Thanks!

  • PO attachment will be attaached in po release strategy workflow

    Hi Gurus, PO creator are adding new attachment(Format : PDF) to  PO (ME22N Transaction). Where this PDF get stored and how to get retrieve this data Becoz need to attach this in mail in workflow. How to attach this file  in PO release strategy workfl

  • Downloading free trial.

    I think I am going to buy photoshop elements 8, But might be downloading the free trial of elements 9 first?  My laptop does not have internet or virus protection.  How likely is it that I could get a virus from going online JUST to download the tria

  • Sales organization wise data

    i want to find out the  data where users have authorization of plantwise - sales organization wise authorization of transactions like VA and XD01