AND_EQUAL hint ignored

Hi,
in my 9.2.0.8 I've got query like:
SELECT /*+ AND_EQUAL(l I_LOK_OPJ_FK I_LOK_DGR_FK) USE_NL(L) USE_NL(OPJ)*/ MAX(lok_audyt_dt)
                    FROM  LIMITY_OKRESY l,  OSOBA_PROGRAM_LOJAL opj,  OSOBY oss
                    WHERE lok_opj_id = opj_id
                    AND opj_osb_id = osb_id
                    AND osb_audyt_st = '1'
                    AND opj_audyt_st = '1'
                    AND lok_audyt_st = '1'
                    and osb_audyt_st = opj_audyt_st
                    and osb_audyt_st = lok_audyt_st
                    and lok_dgr_id = 26
                    AND oss.osb_pesel =  '33010511133'
| Id  | Operation                      |  Name                    | Rows  | Bytes | Cost  |
|   0 | SELECT STATEMENT               |                          |     1 |    57 | 75898 |
|   1 |  SORT AGGREGATE                |                          |     1 |    57 |       |
|   2 |   NESTED LOOPS                 |                          |   929 | 52953 | 75898 |
|   3 |    NESTED LOOPS                |                          |   900 | 34200 |  1198 |
|   4 |     TABLE ACCESS BY INDEX ROWID|  OSOBY                |    92 |  2024 |    94 |
|   5 |      INDEX RANGE SCAN          | I_OSB_PESEL            |    92 |       |     3 |
|   6 |     TABLE ACCESS BY INDEX ROWID|  OSOBA_PROGRAM_LOJAL  |    10 |   160 |    12 |
|   7 |      INDEX RANGE SCAN          | I_OPJ_SYNCHRO2         |    10 |       |     3 |
|   8 |    TABLE ACCESS BY INDEX ROWID |  LIMITY_OKRESY        |     1 |    19 | 75898 |
|   9 |     AND-EQUAL                  |                          |       |       |       |
|  10 |      INDEX RANGE SCAN          | I_LOK_OPJ_FK           |  1363K|       |    80 |
|  11 |      INDEX RANGE SCAN          | I_LOK_DGR_FK           |  1363K|       |    80 |
Note: cpu costing is off, PLAN_TABLE' is old version
    explain plan for
    SELECT /*+ AND_EQUAL(l I_LOK_OPJ_FK I_LOK_DGR_FK) */ MAX(lok_audyt_dt)
                        FROM  LIMITY_OKRESY l,  OSOBA_PROGRAM_LOJAL opj,  OSOBY oss
                        WHERE lok_opj_id = opj_id
                        AND opj_osb_id = osb_id
                        AND osb_audyt_st = '1'
                        AND opj_audyt_st = '1'
                        AND lok_audyt_st = '1'
                        and osb_audyt_st = opj_audyt_st
                       and osb_audyt_st = lok_audyt_st
                       and lok_dgr_id = 26
                       AND oss.osb_pesel =  '33010511133'
Explained.
SQL> select * from table(dbms_xplan.display());
| Id  | Operation                       |  Name                    | Rows  | Bytes | Cost  |
|   0 | SELECT STATEMENT                |                          |     1 |    57 |  1844 |
|   1 |  SORT AGGREGATE                 |                          |     1 |    57 |       |
|   2 |   HASH JOIN                     |                          |   929 | 52953 |  1844 |
|   3 |    TABLE ACCESS BY INDEX ROWID  |  OSOBA_PROGRAM_LOJAL  |    10 |   160 |    12 |
|   4 |     NESTED LOOPS                |                          |   900 | 34200 |  1198 |
|   5 |      TABLE ACCESS BY INDEX ROWID|  OSOBY                |    92 |  2024 |    94 |
|   6 |       INDEX RANGE SCAN          | I_OSB_PESEL            |    92 |       |     3 |
|   7 |      INDEX RANGE SCAN           | I_OPJ_SYNCHRO2         |    10 |       |     3 |
|   8 |    TABLE ACCESS BY INDEX ROWID  |  LIMITY_OKRESY        |  1363K|    24M|   630 |
|   9 |     INDEX RANGE SCAN            | I_LOK_DGR_FK           |  1363K|       |    80 |
Note: cpu costing is off, PLAN_TABLE' is old versionThe first query which respects AND_EQUAL hint runns with 243 cr , the second one which somehow ignores the hint need about 40k cr to complete .
Why CBO is ignoring my and_equal hint I need that for performance .
Please advice.
Regards.
Greg

user10388717 wrote:
Hi,
in my 9.2.0.8 I've got query like:
(snip)
Note: cpu costing is off, PLAN_TABLE' is old version
The first query which respects AND_EQUAL hint runns with 243 cr , the second one which somehow ignores the hint need about 40k cr to complete .
Why CBO is ignoring my and_equal hint I need that for performance .
Please advice.
Regards.
GregGreg,
I do not see anything that would explicitly prevent the AND_EQUAL hint from working, other than an automatic transformation of the SQL statement that only happened when the two nested loop hints were provided. Hints are directives - the optimizer must obey hints unless:
* The hint is invalid due to the wrong alias used in the hint
* The hint is malformed
* The hint is incompatible with another hint
* The query was transformed by the optimizer into a form that is incompatible with the hint before the optimizer applied the hint
* The hint, if followed, would cause the wrong results to be returned
See this article for more information:
http://hoopercharles.wordpress.com/2010/07/19/demonstration-of-oracle-ignoring-an-index-hint/
I would assume that bullet point #4 applies in this case. Examining a 10053 trace, as suggested by riedelme, might help. I believe that the 9i version of a 10053 trace will show how the query is being transformed as it is optimized, just like 10g and above.
Note that the AND_EQUAL hint is deprecated as of Oracle 10g. Jonathan Lewis' "Cost-Based Oracle Fundamentals" book contains a little bit of information about that hint and the AND EQUAL execution path:
http://books.google.com/books?id=TGSd3pkMx5IC&pg=PA457
Charles Hooper
Co-author of "Expert Oracle Practices: Oracle Database Administration from the Oak Table"
http://hoopercharles.wordpress.com/
IT Manager/Oracle DBA
K&M Machine-Fabricating, Inc.

Similar Messages

  • Join hint ignored - very bad query plan results

    I'm trying to get a query that's being generated by SSAS to perform acceptably. Because this query is (at least partially) generated by SSAS, I don't have complete control over the query text.
    The problem - The query looks roughly like this:
    select
    -- a bunch of columns
    from
    T1 -- table with ~40,000,000 rows
    inner loop join T2 on T2.t2id = T1.t2id -- table with ~16,000 rows
    inner loop join T3 on T3.t3id = T1.t3id -- table with ~200,000 rows inner loop join T4 on T4.t4id = T1.t4id -- table with ~200,000 rows
    left loop join T5 on T5.t3id = T1.t3id and T5.t6id = T4.t6id -- table with 0 rows
    where
    -- some uninteresting conditions
    T1 is a Fact (or Measure) table, T2, T3 and T4 are Dimension tables, T5 and T6 are involved in the filtering of the query.  Every row of T1 WILL match exactly one row in each of T1, T2 and T3.
    You'll note that I've hinted all of the joins - according to the documentation, using join hints forces join order (which is consistent with the plan that's produced).  There's no mention that join hints can be transparently ignored by the optimizer,
    but that seems to be precisely what's happening.
    In the plan that results, the join to T4 is done as a hash join, with T1*T2*T3 (40,000,000 rows) on the "top", so it ends up trying to build a hash table with 40,000,000 rows, resulting in very high tempdb activity and very poor performance (I
    don't know how poor - I've never let it finish).
    I can see part of the reason why it's making this join choice - the estimate of T1*T2*T3 is only 35,000 rows, even though T1 has 40,000,000 rows and the join will hit on every row.
    Questions:
    1. What can I do to the query or the database to improve the estimate on the join to T3?
    2. What can I do to the query to force the optimizer to use a loop join like I asked? 
    Version is SQL Server 2008 R2 SP2 Developer Edition X64.
    OS is Windows 2008 R2
    Machine is dual-quad-hyper-threaded CPU with 96Gb of RAM and several Tb of disk spread over 8 spindles and SSDs.
    I've seen this query perform well before - I've been tuning this query for going on 7 years now and I've never seen it perform this badly that I can recall.  Not sure if it's something that's changed in SP2, or something about the distribution
    of data in this particular database that's changed, but something's sure changed.
    -cd Mark the best replies as answers!

    That would indicate that there are no foreign-key constraints, or if they, they are not trusted. (Assuming here that there WHERE clause includes no filter on T1.)
    That, or the statistics on T1 are giving a completely wrong estimates for the number of NULL values in t2id and t3id.
    Erland Sommarskog, SQL Server MVP, [email protected]
    Thanks, Erland.
    There are foreign key constraints, but they're NOCHECK.  I've tried creating and updating statistics on various columns of the tables involved - I'll re-check that I've got up to date statistics on all of the columns involved in these joins.
    What about the join-hint being ignored?  Is there anything I can do, or has something changed here recently?  Interestingly, when I run this query from SSMS, I get loop-joins all around, but when SSAS runs the query, the one join always comes out
    a hash join. Before I added the hints, all joins were hash joins - the hints worked on all joins but the one.
    -cd Mark the best replies as answers!

  • Gather_plan_statistics hint ignored

    Hi,
    I am facing a situation when my gather_plan_statistics hint gets occasionally ignored. ALTER SESSION SET STATISTICS_LEVEL = ALL doesn't help either. I suspect that this may be one of Toad irregularities. I was given advice to run the query in sqlplus to make rowsource stats work. However, there is a problem: I don't know how to suppress the output.
    My concern is that if I don't suppress it, the timing information in the plan will be wrong (because of terminal output being slow).
    I googled and I found suggestion to use set autotrace traceonly. However, it doesn't work because the user doesn't have proper privileges for that (I have to run query under a user that only has access to the application tables, and then use another user to query v$sql, v$sql_statistics etc.).
    So my questions are:
    1) am I right to be concerned about slow terminal output screwing up timing information in the plan?
    2) if yes, then how do I resolve the problem?
    Version information: Oracle 10.2.0.5, Toad 11.0.
    Best regards,
    Nikolay

    Hi,
    sure I can, but it's not suppressing anything:
    SQL> set termout off
    SQL> select 1 from dual connect by level<=50;
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
             1
    50 rows selected.
    SQL>Best regards,
    Nikolay

  • DYNAMIC_SAMPLING Hint Ignored when CONCATENATION operation is used (10g)

    Using 10g (10.2.0.3) I ran into an interesting scenario that really messed up query performance. I found that when the optimizer chose to use CONCATENATION it ignores the DYNAMIC_SAMPLING hint. Has anyone else suffered from this or know of a work-around for this.
    We legitimately use the DYNAMIC_SAMPLING hint because have some correlated columns that are used in the WHERE clause and that is how we get the right cardinality.
    The easiest way to test this is to use this pattern in your WHERE clause:
    WHERE
    text_column like 'A%'
    or text_column like 'B%'
    and any_corrleated_column = <some value>
    That pattern makes the query eligible for the CONCATENATION operation. To force it for testing purposes you have to use the USE_CONCAT hint.
    Our specific data had to do with healthcare. Specifically looking at a specific diagnosis code for a given patient type (inpatient, emergency, observation, etc.)
    The diagnosis code was heavily correlated with the patient type so initial cardinality estimates were off. The DYNAMIC_SAMPLING hint fixed that until the optimizer chose to use CONCATENATION in which case it drastically underestimated the cardinality and used nested loops where it should not have and query performance was hurt.
    Of course the work-around is to use the NO_MERGE hint, but I really don't like using hints that "force" specific access paths because at some point the data may change such that a merge would be appropriate.
    Has anyone tried this on 11g and is the DYNAMIC_SAMPLING preserved?

    Dion, Thanks for your reply.
    We have a lot of analysts who execute their queries directly (OLAP) and that is a conscious choice and we accept the lack of control with performance and tuning individual queries with hints..
    I mention that because in my mind if Oracle is the one that transforms the query from a single table query to use a CONCATENATION operation it should pass on the DYNAMIC_SAMPLING hint to each of the factored queries.
    I agree, there is a lot that could be done with hints, but I really try to avoid hints that lock Oracle into a specific execution path. What I like about DYNAMIC_SAMPLING is I can tell Oracle to challenge its assumptions because I know there are heavily correlated columns in the query.
    When Oracle then samples the data it still has all of the options available to it as far as valid access paths and join types. That is a hint that I will not necessarily have to revisit. Now I could use extended statistics with 11g and that should yield the same effect and maybe I'll just have to wait for us to upgrade to 11g. I really don't want to propagate a lot of hints that I have to think about on every version upgrade.
    Again, thanks for adding to this discussion.

  • [JDev 9.0.3/JClient] ViewObject/Entity attribute: Display Hint ignored?

    I have a small problem with the ability to hide ViewObject/Entity attributes in generated JClient Forms. Hope somebody might know a bit more of this issue.
    When setting the "Display Hint" to "Hide" on an attribute (of either the Entity or ViewObject), the appropriate JLabel and JTextField (or whatever Swing control is used to edit the value) will not be hidden, neither at designtime nor runtime.
    I'm not (yet ;)) an expert when it comes to JClient, but it seems to me that when I tell an attribute of a ViewObject to be hidden, I would expect that the visible property of the appropriate Swing controls be set to false. [ setVisible(false); ]
    In some other thread [ http://forums.oracle.com/forums/message.jsp?id=1342592 ] I read that the problem might be related to setting the control hint AFTER the JClient Form was generated. However, in that same thread someone else suggested that the control hint is processed at runtime. So, I've tried both approaches: first setting the control hint, then generating the JClient Form and first generating the JClient form, then setting the control hint. Neither approach worked.
    However, I did notice that after I set the control hints, the JClient Form wizard allowed me to hide 'hidden' attributes (which indeed were the attributes which I had specified to be hidden). So that worked ok. But even though I unchecked the hidden attributes box, the end result was still the same: a Form with all attributes on it. Running the project revealed that the controls were not hidden at runtime either.
    Am I pherhaps missing something? Or else could this be a bug?
    (As the subject indicates, I'm using JDeveloper 9.0.3 Production Release.)

    Alright, consider this scenario:
    I have a ViewObject with some attributes and in particular the attribute 'X'. In the database table column X is NOT NULL and so attribute X automatically is Mandatory. (This is correctly generated by the BC4J wizard.)
    Next, I manually specify that attribute X is invisible (Display Hint). This should cause any bound Swing controls to become invisible when simply browsing the database. However, when inserting a new record, all controls associated with attribute X should become visible (since X is a Mandatory attribute). After the new record has been committed, the appropriate Swing controls become invisible again.
    I suppose that this behavior could be the same for non Mandatory attributes, but that's (somewhat) less important.
    In case you want a 2nd form in which existing records can be edited (including column X), attribute X should nolonger be invisible. Then the Swing controls bound to attribute X should be removed from the browse form and the 'insert capabilities' of that particular form should be removed as well. The new 2nd should be used for editing/inserting, while the 1st one is for browsing only.
    I realise that this scenario may contain a couple of flaws, but it's to give you an indication of what I'd like to be able to do with the existing wizards and attribute editors.
    Enjoy :)

  • Hint in query

    ear friends,
    my query is like below.
    if you people see i have used Hint in the first query but still my tbl_bank_statement showing Full Table Scan.
    pls. help if i want remove FTS on table what should i modify in below query.
    SELECT /* index(tbl_bank_statement indx_policyno) +*/t1.policy_no AS policy_no, t1.request_no AS request_no,t1.ecs_mandate_status AS ecsmandatestatus ,t1.ecs_micr_code AS ecsmicrcode,t1.createddate  ,t1.userid,t1.ecs_account_no,
    t1.ecs_micr_code,t1.Ecs_Factoring_House,t1.ecs_startdate,t1.ecs_enddate,REJECTIONREASON AS rejectionreason,
    t1.ecs_first_account_holder_name,t1.ecs_second_account_holder_name,t1.ecs_mandate_ref_no,t1.ecs_trd_party_premium_payment
    ,t1.ecs_reln_btn_owner_payor,t1.ecs_account_type,NULL AS REQUESTDATE
    FROM tbl_bank_statement t1
    Where not exists( SELECT t3.serreqid FROM m_ps_otherdetails t3,t_ps_serreq_log ps
    Where t3.policyno = t1.policy_no
    and t3.serreqid =ps.serreqid
    and ps.serreqtypeid in (37,38,39)
    and t3.ECS_Mandate_status = ''4'')
    UNION
    SELECT t2.policyno AS policy_no,t2.serreqid AS request_no,t2.ecs_mandate_status AS ecsmandatestatus,t2.ecs_micr_code AS ecsmicrcode,t2.createddate,t2.createdby AS userid,t2.ecs_account_no,
    t2.ecs_micr_code,t2.Ecs_Factoring_House,t2.ecs_startdate,t2.ecs_enddate,reqlog.rejectionreason,
    2.ecs_first_account_holder_name,t2.ecs_second_account_holder_name,t2.ecs_mandate_ref_no,t2.ecs_trd_party_premium_payment,
    t2.ecs_reln_btn_owner_payor,t2.ecs_account_type, reqlog.REQUESTDATE AS REQUESTDATE
    FROM m_ps_otherdetails t2

    Hints are directives. The only time I've EVER seen a hint ignored is if it creates a situation where it would invalidate the results, or there's a bug in the oracle code itself.
    It will very much not ignore an index hint if it thinks a FTS is 'cheaper'.
    mkr02@ORA11GMK> create table t as select level lvl from dual connect by level < 100000
      2  /
    Table created.
    Elapsed: 00:00:01.53
    mkr02@ORA11GMK> alter table t modify lvl not null
      2  /
    Table altered.
    Elapsed: 00:00:00.83
    mkr02@ORA11GMK> create index idx on t(lvl)
      2  /
    Index created.
    Elapsed: 00:00:00.43
    mkr02@ORA11GMK> explain plan for select lvl from t
      2  /
    Explained.
    Elapsed: 00:00:00.25
    mkr02@ORA11GMK> @xplan
    PLAN_TABLE_OUTPUT
    Plan hash value: 1601196873
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |   108K|  1380K|    47   (3)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| T    |   108K|  1380K|    47   (3)| 00:00:01 |
    Note
       - dynamic sampling used for this statement (level=2)
    12 rows selected.
    Elapsed: 00:00:01.05
    mkr02@ORA11GMK> explain plan for
      2  select /*+ index(t idx) */ lvl from t
      3  /
    Explained.
    Elapsed: 00:00:00.02
    mkr02@ORA11GMK> @xplan
    PLAN_TABLE_OUTPUT
    Plan hash value: 2099009386
    | Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT |      |   108K|  1380K|   237   (1)| 00:00:03 |
    |   1 |  INDEX FULL SCAN | IDX  |   108K|  1380K|   237   (1)| 00:00:03 |
    Note
       - dynamic sampling used for this statement (level=2)
    12 rows selected.
    Elapsed: 00:00:00.06

  • Please explain plan with 'BITMAP CONVERSION TO ROWIDS'

    Hi,
    in my 9.2.0.8 I've got plan like :
    Plan
    SELECT STATEMENT  CHOOSECost: 26,104                           
         7 TABLE ACCESS BY INDEX ROWID UMOWY Cost: 26,105  Bytes: 41  Cardinality: 1                      
              6 BITMAP CONVERSION TO ROWIDS                 
                   5 BITMAP AND            
                        2 BITMAP CONVERSION FROM ROWIDS       
                             1 INDEX RANGE SCAN UMW_PRD_KPD_KOD Cost: 406  Cardinality: 111,930 
                        4 BITMAP CONVERSION FROM ROWIDS       
                             3 INDEX RANGE SCAN UMW_PRD_KPR_KOD Cost: 13,191  Cardinality: 111,930  as far as I know Oracle is trying to combine two indexes , so if I create multicolumn index the plan should be better right ?
    Generally all bitmap conversions related to b-tree indexes are trying to combine multiple indexes to deal with or/ index combine operations right ?
    And finally what about AND_EQUAL hint is that kind of alternative for that bitmap conversion steps ?
    Regards
    Greg

    as far as I know Oracle is trying to combine two indexes , so if I create multicolumn index the plan should be better right ?Only you can really tell - but if this is supposed to be a "precision" query the optimizer thinks you don't have a good index into the target data. Don't forget to consider the benefits of compressed indexes if you do follow this route.
    Generally all bitmap conversions related to b-tree indexes are trying to combine multiple indexes to deal with or/ index combine operations right ?Bitmap conversions when there are no real bitmap indexes involved are always about combining multiple b-tree index range scans to minimise the number of reads from the table.
    And finally what about AND_EQUAL hint is that kind of alternative for that bitmap conversion steps ?AND_EQUAL was an older mechanism for combining index range scans to minimise visits to the table - it was restricted to a maximum of 5 indexes per table - the indexes had to be single column, non-unique, and the predicates had to be equality. The access method is deprecated in 10g. (See the following note, and the comments in particular, for more details: http://jonathanlewis.wordpress.com/2009/05/08/ioug-day-4/ )
    Regards
    Jonathan Lewis

  • Oracle Ignores hint in One Instance and uses the hint in another instance

    Hi Oracle World,
    I am experiencing a strange problem in Oracle.
    We have two oracle servers: one for Test and one for Production.
    We have exactly the same code for a view in both the systems:
    The code is as follows:
    CREATE OR REPLACE FORCE VIEW V_FT(...................)
    AS
    SELECT /*+ star_transformation fact (FT) */
    FT.*, AH.ACCT_1, LH.REGION, FH.FNCT_1
    FROM
    LOCATION_HIERARCHY LH,
    ACCOUNT_HIERARCHY AH,
    FUNCTIONAL_HIERARCHY FH,
    FACT_TABLE FT
    WHERE
    LH.COMPANY = FT.COMPANY
    AND AH.ACCOUNT = FT.ACCOUNT
    AND FH.FUNCTIONR = FT.FUNCTION;
    When I see the execution path:
    In Test box the Explain plan is as expected: It takes the Star_transformation hint into account, converts all three reference table joins to bitmap and performance is good.
    But In Production, It tatally ignores the table name from the hint.
    Also it converts all the tables names to lower case: though it shouldn't impact, I have also tried to give the table names in lower case and then tried. Same issue.
    Tried with NO_MERGE hint. It was pretty good in Test but same issue in Production: it ignoes the table name from hint.
    I have taken out the table name from test and then tested. Now both the explain plans match. That proves oracle ignores the table name in Production.
    We have compared all the parameters in both. They are 100% same. All indexes are analyzed. Can anyone please help what could be the fundamental difference that causes this difference?
    Production takes 8 minutes for a specific query whereas Test returns the same query in 45 secs. Data volume is also not very much different except few hundreds.
    Any pointers please?
    Thanks & Regards
    Saswati

    It is enabled. As I have mentioned we have compared all the parameters in both.
    All v$parameter, init.ora settings everything is same.

  • Oracle 9i ignores INDEX hint

    Hello,
    I try to convince Oracle to do a index scan rather then a full table scan in a query. To
    do this I created a view on top of the table which simply adds this hint:
    CREATE OR REPLACE VIEW V_FHDDSC3_FACT_DATA_4WEEK AS
    SELECT /*+ INDEX(T P_FHDDSC3_FACT_DATA_4WEEK) */
    T.*
    FROM T_FHDDSC3_FACT_DATA_4WEEK T
    The whole query is here:
    SELECT v_fhddsc3_geography_dim.geog_tag, v_fhddsc3_product_dim.prod_tag,
    v_fhddsc3_time_4week_dim.time_tag, v_fhddsc3_fact_data_4week.m001,
    v_fhddsc3_fact_data_4week.m002, v_fhddsc3_fact_data_4week.m003,
    v_fhddsc3_fact_data_4week.m004, v_fhddsc3_fact_data_4week.m005,
    v_fhddsc3_fact_data_4week.m006, v_fhddsc3_fact_data_4week.m007,
    v_fhddsc3_fact_data_4week.m008, v_fhddsc3_fact_data_4week.m009,
    v_fhddsc3_fact_data_4week.m010
    FROM v_fhddsc3_geography_dim,
    v_fhddsc3_time_4week_dim,
    v_fhddsc3_fact_data_4week,
    v_fhddsc3_product_dim
    WHERE ( v_fhddsc3_geography_dim.geog_key =
    v_fhddsc3_fact_data_4week.geog_key
    AND v_fhddsc3_product_dim.prod_key =
    v_fhddsc3_fact_data_4week.prod_key
    AND v_fhddsc3_time_4week_dim.time_key =
    v_fhddsc3_fact_data_4week.time_key
    AND ( v_fhddsc3_geography_dim.geog_tag IN
    (:"SYS_B_00",
    :"SYS_B_01",
    :"SYS_B_02",
    :"SYS_B_03",
    :"SYS_B_04",
    :"SYS_B_05",
    :"SYS_B_06",
    :"SYS_B_07",
    :"SYS_B_08"
    AND v_fhddsc3_product_dim.hierarchy_level IN (:"SYS_B_09")
    AND v_fhddsc3_time_4week_dim.time_tag IN
    (:"SYS_B_10",
    :"SYS_B_11",
    :"SYS_B_12",
    :"SYS_B_13",
    :"SYS_B_14",
    :"SYS_B_15",
    :"SYS_B_16",
    :"SYS_B_17",
    :"SYS_B_18",
    :"SYS_B_19",
    :"SYS_B_20",
    :"SYS_B_21",
    :"SYS_B_22",
    :"SYS_B_23",
    :"SYS_B_24",
    :"SYS_B_25",
    :"SYS_B_26",
    :"SYS_B_27",
    :"SYS_B_28",
    :"SYS_B_29",
    :"SYS_B_30",
    :"SYS_B_31",
    :"SYS_B_32",
    :"SYS_B_33",
    :"SYS_B_34",
    :"SYS_B_35",
    :"SYS_B_36"
    The execution plan shows a full table scan on T_FHDDSC3_FACT_DATA_4WEEK.
    The index is the primary key of the table containing PROD_KEY, GEOG_KEY and TIME_KEY.
    Why is Oracle 9i ignoring index hints?
    I came across the same problem some months ago, when we migrated one database from 8i to 9i. After that an INDEX_ASC hint was suddenly ignored. We used an index + and INDEX_ASC hint to sort a hierarchical query.
    We had to change the algorithmn and use a Database function to get it sorted right. This is painfull and slow.
    Any ideas?
    Kai

    Kai,
    Remember a hint is just that, a hint to the optimizer, it does not override the execution plan created by the optimizer. Possibilities are that the statistics in the database are out of date, which will affect the Cost based optimizer. Indexes on views are tricky as they would rely on the indexes on the underlying tables.
    Few AskTom links which may help:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:1705043::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:313416745628,%7Bhint%7D%20and%20%7Bindex%7D
    http://asktom.oracle.com/pls/ask/f?p=4950:8:1705043::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:641623836427,%7Bhint%7D%20and%20%7Bindex%7D
    http://asktom.oracle.com/pls/ask/f?p=4950:8:1705043::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:1197786003246,%7Bhint%7D%20and%20%7Bindex%7D
    Sometimes the full scan can be quicker, than the index depending on the query.
    Regds
    Dave

  • Ignore hints global settings

    Hi all,
    I know I can set ``ignore hints`` setting for current session.
    Is it possible to set it globally, for all sessions?
    alter session set "_optimizer_ignore_hints" = TRUE ;

    works for me, at session or instance level:
    orclz> alter system set "_optimizer_ignore_hints" = false ;
    System altered.
    orclz> select /*+ full(emp) */ * from emp where empno=1000;
    no rows selected
    Execution Plan
    Plan hash value: 3956160932
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |    38 |     3   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| EMP  |     1 |    38 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("EMPNO"=1000)
    orclz> alter system set "_optimizer_ignore_hints" = TRUE ;
    System altered.
    orclz> select * from emp where empno=1000;
    no rows selected
    Execution Plan
    Plan hash value: 2949544139
    | Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |        |     1 |    38 |     1   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    38 |     1   (0)| 00:00:01 |
    |*  2 |   INDEX UNIQUE SCAN         | PK_EMP |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("EMPNO"=1000)
    orclz> select /*+ full(emp) */ * from emp where empno=1000;
    no rows selected
    Execution Plan
    Plan hash value: 2949544139
    | Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |        |     1 |    38 |     1   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    38 |     1   (0)| 00:00:01 |
    |*  2 |   INDEX UNIQUE SCAN         | PK_EMP |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("EMPNO"=1000)
    orclz>
    orclz>
    Message was edited by: JohnWatson
    update: corrected the font.

  • KDE4 ignores font hinting settings [solved: qt bug, fixed in 4.5]

    Full hinting enabled in Gnome and KDE:
    Slight hinting enabled in Gnome and KDE:
    KDE seems to ignore the hinting settings. It's present in ~/.fonts.conf, also Qt3 apps work fine.
    I would like to use slight hinting everywhere, but KDE4 defaults to full hinting anyway
    Google wasn't very helpful on this issue, and I found no mention of it in the KDE bugzilla.
    Last edited by eWoud (2008-10-05 10:34:21)

    Edit2: Oops, ignore my patch - it doesn't work. Qt4 doesn't even use cairo.
    Last edited by brebs (2008-10-10 02:24:04)

  • View is ignoring the hints

    I am using Oracle 10g R2.
    I want to pass hints to a view but they are not being honoured.
    CREATE VIEW V AS
         SELECT DT.UNIQUE_ID,
                DT.INFO_ID AS BATCH_REFERENCE,
                DT.INSTRUCTION_ID AS TR_REFERENCE,
                DT.TOTAL_TRANSACTION_NO AS NO_OF_TRANSACTIONS,
           FROM    MY_PAYMENT DT JOIN MY_STATUS ST
                 ON DT.BATCH_STATUS = ST.STATUS;
    Now when I run the below query, then hints are ignored. However if i pass the INDEX hint directly in the above SELECT in the view definition, then hints are honoured.
    SELECT /*+ INDEX(V.DT) */ * FROM V
    Can you help?

    Moazzam wrote:
    So what is the objective behind using a HINT to force an index scan?
    Actually, the statistics gathering job takes more than 16 hours to complete. Due to which, most of the time, the plan generated are not optimized due to lack of up to date stats.
    In that case trying to bypass the actual issue by using HINT does not look like a wise idea to me. Any ways you need to use GLOBAL HINT when using VIEW.
    Oracle documented it in detail. You can read it here
    http://docs.oracle.com/cd/B19306_01/server.102/b14211/hintsref.htm#i22065
    Below is a simple example using EMP and DEPT table.
    Following is the view
    SQL> create view v
      2  as
      3  select d.dname, e.ename
      4    from emp e join dept d
      5      on e.deptno = d.deptno;
    View created.
    Now plan for the query with and without hint
    SQL> explain plan for
      2  select e.ename, d.dname from emp e join dept d on e.deptno = d.deptno;
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 14164142
    | Id  | Operation                    | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |         |    11 |   242 |     4  (25)| 00:00:01 |
    |   1 |  MERGE JOIN                  |         |    11 |   242 |     4  (25)| 00:00:01 |
    |   2 |   TABLE ACCESS BY INDEX ROWID| DEPT    |     4 |    52 |     1   (0)| 00:00:01 |
    |   3 |    INDEX FULL SCAN           | DEPT_PK |     4 |       |     1   (0)| 00:00:01 |
    |*  4 |   SORT JOIN                  |         |    11 |    99 |     3  (34)| 00:00:01 |
    |   5 |    TABLE ACCESS FULL         | EMP     |    11 |    99 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - access("E"."DEPTNO"="D"."DEPTNO")
           filter("E"."DEPTNO"="D"."DEPTNO")
    18 rows selected.
    SQL> explain plan for
      2  select /*+ INDEX(e emp_pk) */ e.ename, d.dname from emp e join dept d on e.deptno = d.deptno;
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 2399836226
    | Id  | Operation                     | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT              |         |    11 |   242 |     3  (34)| 00:00:01 |
    |   1 |  MERGE JOIN                   |         |    11 |   242 |     3  (34)| 00:00:01 |
    |   2 |   TABLE ACCESS BY INDEX ROWID | DEPT    |     4 |    52 |     1   (0)| 00:00:01 |
    |   3 |    INDEX FULL SCAN            | DEPT_PK |     4 |       |     1   (0)| 00:00:01 |
    |*  4 |   SORT JOIN                   |         |    11 |    99 |     2  (50)| 00:00:01 |
    |   5 |    TABLE ACCESS BY INDEX ROWID| EMP     |    11 |    99 |     1   (0)| 00:00:01 |
    |   6 |     INDEX FULL SCAN           | EMP_PK  |    11 |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - access("E"."DEPTNO"="D"."DEPTNO")
           filter("E"."DEPTNO"="D"."DEPTNO")
    19 rows selected.
    Now plan for the query on view with and without hint
    SQL> explain plan for
      2  select * from v;
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 14164142
    | Id  | Operation                    | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |         |    11 |   242 |     4  (25)| 00:00:01 |
    |   1 |  MERGE JOIN                  |         |    11 |   242 |     4  (25)| 00:00:01 |
    |   2 |   TABLE ACCESS BY INDEX ROWID| DEPT    |     4 |    52 |     1   (0)| 00:00:01 |
    |   3 |    INDEX FULL SCAN           | DEPT_PK |     4 |       |     1   (0)| 00:00:01 |
    |*  4 |   SORT JOIN                  |         |    11 |    99 |     3  (34)| 00:00:01 |
    |   5 |    TABLE ACCESS FULL         | EMP     |    11 |    99 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - access("E"."DEPTNO"="D"."DEPTNO")
           filter("E"."DEPTNO"="D"."DEPTNO")
    18 rows selected.
    Now we use GLOBAL TABLE HINT
    SQL> explain plan for
      2  select /*+ INDEX(@SEL$2 e emp_pk) */ * from v;
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 2399836226
    | Id  | Operation                     | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT              |         |    11 |   242 |     3  (34)| 00:00:01 |
    |   1 |  MERGE JOIN                   |         |    11 |   242 |     3  (34)| 00:00:01 |
    |   2 |   TABLE ACCESS BY INDEX ROWID | DEPT    |     4 |    52 |     1   (0)| 00:00:01 |
    |   3 |    INDEX FULL SCAN            | DEPT_PK |     4 |       |     1   (0)| 00:00:01 |
    |*  4 |   SORT JOIN                   |         |    11 |    99 |     2  (50)| 00:00:01 |
    |   5 |    TABLE ACCESS BY INDEX ROWID| EMP     |    11 |    99 |     1   (0)| 00:00:01 |
    |   6 |     INDEX FULL SCAN           | EMP_PK  |    11 |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - access("E"."DEPTNO"="D"."DEPTNO")
           filter("E"."DEPTNO"="D"."DEPTNO")
    19 rows selected.
    SQL>

  • Execute immediate ignoring hints

    Hi
    I'm looking for help about an unexpected behavior in oracle. I have a query that it is executed by a stored procedure, and this query has some hints to improve its performance. When I execute the procedure with sqlplus or any other tool, using "exec myprocedure;", the process took between 30 and 40 minutes to complete. But if I call this procedure inside another procedure with execute immediate command, it took more than 5 hours to complete.
    The procedure code is
    execute immediate 'begin '||proc||'; end;';
    proc is a variable that contain the procedure name to run
    It seems that oracle are ignoring my hints when it is executed by execute immediate command. In all tests that I've done I used the same user to connect.
    The version of oracle is 9.2.0
    Tks for any help

    > Why would you do this?
    Presumably he has a variable like "v_which_procedure" which could have the values 'RAISE_PAY()' or 'FIRE_ALL_EMPLOYEES()', and some logic that determines which to use.
    I would agree though that in general it would be better to structure things so that you are not in the position of slotting the name of a procedure dynamically into an EXECUTE IMMEDIATE call.
    I don't see how SQL inside a procedure would know that the procedure itself was called dynamically, so the fact that it seems to be performing differently is a bit of a mystery. I would want to be absolutely sure that that was actually what it was doing.

  • Use_concat hint being ignored

    Hallo,
    Oracle ignores the "use_concat" hint in my query. I wonder why.
    Oracle Database 10g Release 10.2.0.4.0 - 64bit Production
    The Query looks like:
    SELECT /*+ USE_CONCAT */   SUMMARY_ID, DB_ID
          FROM
              PROCESS_SUMMARY
          WHERE
          ( TOOL = 'tool_1' AND LOT_ID = 'ABCDEF-124')
          OR
          ( TOOL = 'tool_1' AND SUBSTR(LOT_ID,1,6) = 'ABCDEF' AND END_TIME between sysdate-1 AND sysdate); there is an b-tree index (TOOL,LOT_ID)
    --> causes a FULL table access, COST 13042
    autotrace:
    >
    recursive calls     1
    db block gets     0
    consistent gets     61365
    physical reads     61321
    redo size     0
    bytes sent via SQL*Net to client     763
    bytes received via SQL*Net from client     896
    SQL*Net roundtrips to/from client     2
    >
    Rewriting the query manually into a UNION:
    SELECT SUMMARY_ID, DB_ID
          FROM
              PROCESS_SUMMARY
          WHERE
          TOOL = 'tool_1' AND LOT_ID = 'ABCDEF-124'
    UNION
    SELECT SUMMARY_ID, DB_ID
          FROM
              PROCESS_SUMMARY
          WHERE
          TOOL = 'tool_1' AND SUBSTR(LOT_ID,1,6) = 'ABCDEF' AND END_TIME between sysdate-1 AND sysdate;-->union all with index range scans performed, COST: 6208
    autotrace:
    >
    recursive calls     1
    db block gets     0
    consistent gets     5025
    physical reads     515
    redo size     0
    bytes sent via SQL*Net to client     815
    bytes received via SQL*Net from client     1041
    SQL*Net roundtrips to/from client     2
    sorts (memory)     2
    sorts (disk)     0
    >
    so why is oracle ignoring the USE_CONCAT hint?
    that's not a catastrophy, as i can transform the query manually. just wondering why.
    thanks a lot.

    check
    alter session set "_NO_OR_EXPANSION"=true;
    explain plan for select /*+ USE_CONCAT */   summary_id, db_id
          from
              process_summary
          where
          ( tool = 'tool_1' and lot_id = 'ABCDEF-124')
          or
          ( tool = 'tool_1' and substr(lot_id,1,6) = 'ABCDEF' and end_time between sysdate-1 and sysdate);
    select * from table(dbms_xplain.display);
    alter session set "_NO_OR_EXPANSION"=false;
    explain plan for select /*+ USE_CONCAT */   summary_id, db_id
          from
              process_summary
          where
          ( tool = 'tool_1' and lot_id = 'ABCDEF-124')
          or
          ( tool = 'tool_1' and substr(lot_id,1,6) = 'ABCDEF' and end_time between sysdate-1 and sysdate);
    select * from table(dbms_xplain.display);

  • Fast Refresh MVs and HASH_SJ Hint

    I am building fast refresh MVs on a 3rd party database to enable faster reporting. This is an interim solution whilst we build a new ETL process using CDC.
    The source DB has no PKs, so I'm creating the MV logs with ROWID. When I refresh the MV (exec DBMS_MVIEW.REFRESH('<mview_name>') and trace the session I notice:
    1. The query joins back to the base table - I think this is necessary as there are two base tables and the MV change could be instigated from either table independently. Therefore the changes might not be in the log.
    2. However in this case shouldn't it be possible to just joij mv_log1 to base_table2 and ignore base_table1?
    3. There is a HASH_SJ hint in this join, forcing a full table scan on the 7M row base_table1.
    4. I am doing 1 update then refreshing the MV
    5. In production this table would have many 10s of single row inserts and updates per minute
    This is an excerpt from the tkprof'd trace file (I've hidden some table/column names)
    FROM   (SELECT MAS$.ROWID RID$ 
                  ,MAS$.* 
            FROM   <base_table1> MAS$
            WHERE  ROWID IN (SELECT  /*+ HASH_SJ */ 
                                    CHARTOROWID(MAS$.M_ROW$$) RID$    
                             FROM   <mview_log1> MAS$  
                             WHERE  MAS$.SNAPTIME$$ > sysdate-1/24 --:1
           ) AS OF SNAPSHOT (:2) JV$
           ,<base_table2> AS OF SNAPSHOT (:2)  MAS$0
    WHERE   JV$.<col1>=MAS$0.<col1>
    AND     JV$.<col2>=MAS$0.<col2>
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1     13.78     153.32     490874     551013          3           1
    Fetch        0      0.00       0.00          0          0          0           0
    total        2     13.78     153.32     490874     551013          3           1
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 277  (<user>)   (recursive depth: 1)
    Rows     Row Source Operation
          1  TABLE ACCESS BY INDEX ROWID <base_table2>(cr=551010 pr=490874 pw=0 time=153321352 us)
          3   NESTED LOOPS  (cr=551009 pr=490874 pw=0 time=647 us)
          1    VIEW  (cr=551006 pr=490874 pw=0 time=153321282 us)
          1     HASH JOIN RIGHT SEMI (cr=551006 pr=490874 pw=0 time=153321234 us)
          2      TABLE ACCESS FULL <base_table1_mv_log> (cr=21 pr=0 pw=0 time=36 us)
    7194644      TABLE ACCESS FULL <base_table1>(cr=550985 pr=490874 pw=0 time=158282171 us)
          1    INDEX RANGE SCAN <base_table2_index> (cr=3 pr=0 pw=0 time=22 us)(object id 3495055)As you can see there are two rows in the MV log (one update, old and new values), the FTS on the base table ensure that the MV refresh is far from fast
    I have tried this with refreshing on demand and commit with similar results. Implementing this would make my the application impossibly slow.
    I will search the knowledge base once I am given access
    SQL>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 64-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - ProductionThank you for taking the time to read/respond.
    Ben

    Thanks for looking.
    From the Knowledge Base it appears that Bug 6456841 might be the cause. I'll play around with the settings it suggests and see what happens.
    the MV query is basically:
    SELECT ...
    FROM   base_table1
          ,base_table2
    WHERE  base_table1.col1 = base_table2.col1
    AND    base_table1.col2 = base_table2.col2When 1 row in base_table1 is updated there is a FTS for that table, rather than:
    1. getting the data from the MV log or
    2. a Nested loop join to base_table1 from its mv_log on rowid
    This is due to the oracle internal code putting a HASH_SJ hint in when joining the mv log to its base table
    Ben

Maybe you are looking for