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

Similar Messages

  • Can Oracle pick an index hint for an index that's inside of a sub query?

    I have a query like the following:
    Select /*INDEX(Table1 TABLE1_IDX) INDEX(Table3 Table3_IDX) */
    from (select /*INDEX(Table1 TABLE1_IDX) */
    T1.col1,t1.col2,...
    from Table1 T1
    Join Table2 T2
    ON T1.col1 = T2.col1
    T1.col2 = T2.col2) Tsub
    Right Outer Join Table3 T3
    ON T3.col1 = Tsub.col1
    T3.col2 = Tsub.col2
    Will Oracle pick up and use the index for Table1 in the join to Table3 even though it's being refernced from with in a sub-select statement? Will it know to use the index for the 'Tsub' alias to join it to Table3?

    "Hints apply only to the optimization of the block of a statement in which they appear. A statement block is any one of the following statements or parts of statements:
    A simple SELECT, UPDATE, or DELETE statement
    A parent statement or subquery of a complex statement
    A part of a compound query"
    however, your outer query has NOTHING named "table1". hints must use the ALIAS (if one is given), so your outer hint for table1_idx should reference "TSUB".
    but even more to the point, once the subquery is complete, you'll outer-join table3 to it, which doesn't need an index on tsub.

  • SQL query performance difference with Index Hint in Oracle 10g

    Hi,
    I was having a problem in SQL select query which was taking around 20 seconds to get the results. So, by hit and trail method I added Index Oracle Hint into the same query with the list of indexes of the tables and the results are retrieved with in 10 milli seconds. I am not sure to get How this is working with Indexes Hint.
    The query with out Index Hint:
    select /*+rule*/ FdnTab2.fdn, paramTab3.attr_name from fdnmappingtable FdnTab, fdnmappingtable FdnTab2, parametertable paramTab1 ,parametertable paramTab3  where FdnTab.id=52787 and paramTab1.id= FdnTab.id  and paramTab3.id = FdnTab.id  and paramTab3.attr_value = FdnTab2.fdn  and paramTab1.attr_name='harqUsersMax' and paramTab1.attr_value <> 'DEFAULT' and exists ( select ParamTab2.attr_name from parametertable ParamTab2, templaterelationtable TemplateTab2  where TemplateTab2.id=FdnTab.id  and ParamTab2.id=TemplateTab2.template_id  and ParamTab2.id=FdnTab2.id  and ParamTab2.attr_name=paramTab1.attr_name)  ==> EXECUTION TIME: 20 secs
    The same query with Index Hint:
    select /*+INDEX(fdnmappingtable[PRIMARY_KY_FDNMAPPINGTABLE],parametertable[PRIMARY_KY_PARAMETERTABLE])*/ FdnTab2.fdn, paramTab3.attr_name from fdnmappingtable FdnTab, fdnmappingtable FdnTab2, parametertable paramTab1 ,parametertable paramTab3 where FdnTab.id=52787 and paramTab1.id= FdnTab.id and paramTab3.id = FdnTab.id and paramTab3.attr_value = FdnTab2.fdn and paramTab1.attr_name='harqUsersMax' and paramTab1.attr_value <> 'DEFAULT' and exists ( select ParamTab2.attr_name from parametertable ParamTab2, templaterelationtable TemplateTab2 where TemplateTab2.id=FdnTab.id and ParamTab2.id=TemplateTab2.template_id and ParamTab2.id=FdnTab2.id and ParamTab2.attr_name=paramTab1.attr_name) ==> EXECUTION TIME: 10 milli secs
    Can any one suggest what could be the real problem?
    Regards,
    Purushotham

    Sorry,
    The right query and the explain plan:
    select /*+rule*/ FdnTab2.fdn, paramTab3.attr_name from fdnmappingtable FdnTab, fdnmappingtable FdnTab2, parametertable paramTab1 ,parametertable paramTab3  where FdnTab.id=52787 and paramTab1.id= FdnTab.id  and paramTab3.id = FdnTab.id  and paramTab3.attr_value = FdnTab2.fdn  and paramTab1.attr_name='harqUsersMax' and paramTab1.attr_value <> 'DEFAULT' and exists ( select ParamTab2.attr_name from parametertable ParamTab2, templaterelationtable TemplateTab2  where TemplateTab2.id=FdnTab.id  and ParamTab2.id=TemplateTab2.template_id  and ParamTab2.id=FdnTab2.id  and ParamTab2.attr_name=paramTab1.attr_name) 
    SQL> @$ORACLE_HOME/rdbms/admin/utlxpls.sql
    PLAN_TABLE_OUTPUT
    Plan hash value: 651267974
    | Id | Operation | Name |
    | 0 | SELECT STATEMENT | |
    |* 1 | FILTER | |
    | 2 | NESTED LOOPS | |
    | 3 | NESTED LOOPS | |
    | 4 | NESTED LOOPS | |
    |* 5 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
    PLAN_TABLE_OUTPUT
    |* 6 | TABLE ACCESS BY INDEX ROWID| PARAMETERTABLE |
    |* 7 | INDEX UNIQUE SCAN | PRIMARY_KY_PARAMETERTABLE |
    | 8 | TABLE ACCESS BY INDEX ROWID | PARAMETERTABLE |
    |* 9 | INDEX RANGE SCAN | PRIMARY_KY_PARAMETERTABLE |
    | 10 | TABLE ACCESS BY INDEX ROWID | FDNMAPPINGTABLE |
    |* 11 | INDEX UNIQUE SCAN | SYS_C005695 |
    | 12 | NESTED LOOPS | |
    |* 13 | INDEX UNIQUE SCAN | PRIMARY_KY_PARAMETERTABLE |
    |* 14 | INDEX UNIQUE SCAN | PRIMARY_KEY_TRTABLE |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
    1 - filter( EXISTS (SELECT 0 FROM "TEMPLATERELATIONTABLE"
    "TEMPLATETAB2","PARAMETERTABLE" "PARAMTAB2" WHERE
    "PARAMTAB2"."ATTR_NAME"=:B1 AND "PARAMTAB2"."ID"=:B2 AND
    "PARAMTAB2"."ID"="TEMPLATETAB2"."TEMPLATE_ID" AND
    "TEMPLATETAB2"."ID"=:B3))
    5 - access("FDNTAB"."ID"=52787)
    6 - filter("PARAMTAB1"."ATTR_VALUE"<>'DEFAULT')
    7 - access("PARAMTAB1"."ID"="FDNTAB"."ID" AND
    PLAN_TABLE_OUTPUT
    "PARAMTAB1"."ATTR_NAME"='harqUsersMax')
    9 - access("PARAMTAB3"."ID"="FDNTAB"."ID")
    11 - access("PARAMTAB3"."ATTR_VALUE"="FDNTAB2"."FDN")
    13 - access("PARAMTAB2"."ID"=:B1 AND "PARAMTAB2"."ATTR_NAME"=:B2)
    14 - access("TEMPLATETAB2"."ID"=:B1 AND
    "PARAMTAB2"."ID"="TEMPLATETAB2"."TEMPLATE_ID")
    Note
    - rule based optimizer used (consider using cbo)
    43 rows selected.
    WITH INDEX HINT:
    select /*+INDEX(fdnmappingtable[PRIMARY_KY_FDNMAPPINGTABLE],parametertable[PRIMARY_KY_PARAMETERTABLE])*/ FdnTab2.fdn, paramTab3.attr_name from fdnmappingtable FdnTab, fdnmappingtable FdnTab2, parametertable paramTab1 ,parametertable paramTab3 where FdnTab.id=52787 and paramTab1.id= FdnTab.id and paramTab3.id = FdnTab.id and paramTab3.attr_value = FdnTab2.fdn and paramTab1.attr_name='harqUsersMax' and paramTab1.attr_value <> 'DEFAULT' and exists ( select ParamTab2.attr_name from parametertable ParamTab2, templaterelationtable TemplateTab2 where TemplateTab2.id=FdnTab.id and ParamTab2.id=TemplateTab2.template_id and ParamTab2.id=FdnTab2.id and ParamTab2.attr_name=paramTab1.attr_name);
    SQL> @$ORACLE_HOME/rdbms/admin/utlxpls.sql
    PLAN_TABLE_OUTPUT
    Plan hash value: 2924316070
    | Id | Operation | Name | Rows | B
    ytes | Cost (%CPU)| Time |
    PLAN_TABLE_OUTPUT
    | 0 | SELECT STATEMENT | | 1 |
    916 | 6 (0)| 00:00:01 |
    |* 1 | FILTER | | |
    | | |
    | 2 | NESTED LOOPS | | 1 |
    916 | 4 (0)| 00:00:01 |
    | 3 | NESTED LOOPS | | 1 |
    401 | 3 (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    | 4 | NESTED LOOPS | | 1 |
    207 | 2 (0)| 00:00:01 |
    |* 5 | TABLE ACCESS BY INDEX ROWID| PARAMETERTABLE | 1 |
    194 | 1 (0)| 00:00:01 |
    |* 6 | INDEX UNIQUE SCAN | PRIMARY_KY_PARAMETERTABLE | 1 |
    | 1 (0)| 00:00:01 |
    |* 7 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE | 1 |
    PLAN_TABLE_OUTPUT
    13 | 1 (0)| 00:00:01 |
    | 8 | TABLE ACCESS BY INDEX ROWID | PARAMETERTABLE | 1 |
    194 | 1 (0)| 00:00:01 |
    |* 9 | INDEX RANGE SCAN | PRIMARY_KY_PARAMETERTABLE | 1 |
    | 1 (0)| 00:00:01 |
    | 10 | TABLE ACCESS BY INDEX ROWID | FDNMAPPINGTABLE | 1 |
    515 | 1 (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |* 11 | INDEX UNIQUE SCAN | SYS_C005695 | 1 |
    | 1 (0)| 00:00:01 |
    | 12 | NESTED LOOPS | | 1 |
    91 | 2 (0)| 00:00:01 |
    |* 13 | INDEX UNIQUE SCAN | PRIMARY_KEY_TRTABLE | 1 |
    26 | 1 (0)| 00:00:01 |
    |* 14 | INDEX UNIQUE SCAN | PRIMARY_KY_PARAMETERTABLE | 1 |
    65 | 1 (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
    1 - filter( EXISTS (SELECT /*+ */ 0 FROM "TEMPLATERELATIONTABLE" "TEMPLATETAB
    2","PARAMETERTABLE"
    PLAN_TABLE_OUTPUT
    "PARAMTAB2" WHERE "PARAMTAB2"."ATTR_NAME"=:B1 AND "PARAMTAB2"."ID"
    =:B2 AND
    "TEMPLATETAB2"."TEMPLATE_ID"=:B3 AND "TEMPLATETAB2"."ID"=:B4))
    5 - filter("PARAMTAB1"."ATTR_VALUE"<>'DEFAULT')
    6 - access("PARAMTAB1"."ID"=52787 AND "PARAMTAB1"."ATTR_NAME"='harqUsersMax')
    7 - access("FDNTAB"."ID"=52787)
    9 - access("PARAMTAB3"."ID"=52787)
    11 - access("PARAMTAB3"."ATTR_VALUE"="FDNTAB2"."FDN")
    13 - access("TEMPLATETAB2"."ID"=:B1 AND "TEMPLATETAB2"."TEMPLATE_ID"=:B2)
    14 - access("PARAMTAB2"."ID"=:B1 AND "PARAMTAB2"."ATTR_NAME"=:B2)
    PLAN_TABLE_OUTPUT
    Note
    - dynamic sampling used for this statement
    39 rows selected.

  • 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>

  • Accessing the records in ascending order using index hint

    I am getting a problem in selecting the rows using the index hint which in i want to query in the ascending order.
    for eg.
    select /*+ index(temp_itr_header,tmp_itrhdr_1#IDX2) */ person_id
    from temp_itr_header

    Oracle knows that it doesn't have to resort data if it accessed individual rows from an index with the same sort order. In other words, adding the ORDER BY clause need not cause Oracle to do any extra work. Adding the ORDER BY does guarantee that the results will be sorted and will tend to cause Oracle to use the index, assuming it can avoid the sort that way. If you don't have an ORDER BY, Oracle is free to return rows in whatever order it would like regardless of your hint.
    If you want to use the index hint, the syntax is
    SELECT /*+ INDEX(temp_itr_header <<index name>>) */Note that you do not want to have a comma in your hint. Of course, if your statistics are accurate, you shouldn't need to resort to a hint here-- the CBO should pick the most efficient path.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Performance problem because of ignored index

    Hi,
    We have a performance problem with kodo ignoring indexes in Oracle:
    Our baseclass of all our persistent classes (LogasPoImpl) has a subclass
    CODEZOLLMASSNAHMENIMPL.
    We use vertical mapping for all subclasses and have 400.000 instances of
    CODEZOLLMASSNAHMENIMPL.
    We defined an additional index on an attribute of CODEZOLLMASSNAHMENIMPL.
    A query with a filter like "myIndexedAttribute = 'DE'" takes about 15
    seconds on Oracle 8.1.7.
    Kodo logs something like the following:
    [14903 ms] executing prepstmnt 6156689 SELECT (...)
    FROM CODEZOLLMASSNAHMENIMPL t0, LOGASPOIMPL t1
    WHERE (t0.myIndexedAttribute = ?)
    AND t1.JDOCLASS = ?
    AND t0.JDOID = t1.JDOID
    [params=(String) DE, (String)
    de.logas.zoll.eztneu.CodeZollMassnahmenImpl] [reused=0]
    When I execute the same statement from a SQL-prompt, it takes that long as
    well, but when I swap the tablenames in the from part
    (to "FROM LOGASPOIMPL t1, CODEZOLLMASSNAHMENIMPL t0") the result comes
    immediately.
    I've had a look at the query plans, oracle creates for the two statements
    and found, that our index on myIndexedAttribute is not used
    by the first statement, but it is by the second.
    How can I make Kodo use the faster statement?
    I've tried to use the "jdbc-indexed" tag, but without success so far.
    Thanks,
    Wolfgang

    Thank you very much, Stefan & Alex.
    After computing statistics the index is used and the performance is fine
    now.
    - Wolfgang
    Alex Roytman wrote:
    ANALYZE TABLE MY_TABLE COMPUTE STATISTICS;
    "Stefan" <[email protected]> wrote in message
    news:btlqsj$f18$[email protected]..
    When I execute the same statement from a SQL-prompt, it takes that longas
    well, but when I swap the tablenames in the from part
    (to "FROM LOGASPOIMPL t1, CODEZOLLMASSNAHMENIMPL t0") the result comes
    immediately.
    I've had a look at the query plans, oracle creates for the twostatements
    and found, that our index on myIndexedAttribute is not used
    by the first statement, but it is by the second.
    How can I make Kodo use the faster statement?
    I've tried to use the "jdbc-indexed" tag, but without success so far.I know that in DB2 there is a function called "Run Statistics" which you
    can (and should do) on all tables involved in a query (at least once a
    month, when there are heavy changes in the tables).
    On information gathered by this statistics DB2 can optimize your queries
    and execution path's
    Since I was once involved in query performance optimizing on DB/2 I can
    say you can get improvements of 80% on big tables on which statistics are
    run and not. (Since the execution plans created by the optimizer differ
    heavily)
    Since I'm working now with Oracle as well, at least I can say, that Oracle
    has a featere like statistics as well. (go into the manager enterprise
    Console and click on a table, you will find a row "statisitics last run")
    I don't know how to trigger these statistics nor whether they would
    influence the query execution path on oracle (thus "swapping" tablenames
    by itself), since I didn't have time to do further research on thatmatter.
    But it's worth a try to find out and maybe it helps on you problem ?

  • Doubt with index hint

    I have a doubt with applying the index hint to fire for multiple coulmns in a query.
    For a single column, it is ok like:-
    select /*+ index( ppbS_inv_sim_serial iss_status) */ item_type_id, status, city from
    ppbS_inv_sim_serial where status='IT';
    there is a problem with indexes firing in our database so this way, using hint, the
    indexes fire.
    But, what, if i want all 3 indexes in the query to fire like
    select count(1) from
    ppbS_inv_sim_serial where status='IT' and item_type_id='A2' and city='USA';
    I hope, my question is clear. Please, help i solving my doubt as it is urgent.
    regards.

    Fix the problem. Not the symptom.
    Using hints in SQL, especially production SQL, is a very poor way to address the problem and only fix the symptom for a period. Until the problem rears its head again and bite you in the butt - a lot more painful this time around.
    Solving performance problems start with Rule #1.
    RULE 1#. IDENTIFY THE PERFORMANCE PROBLEM
    Saying that something is slow, is not identifying the problem. The only way a problem can be solved is if you have at least some idea what the actual problem is.
    Identifying the problem will point to issues like:
    - database schema(s) not being analysed or analysed correctly
    - poorly designed and written SQL (often the case)
    - poorly configured Oracle instance
    - problem/bug(?) with the Oracle CBO
    And depending on the problem analysis, the problem can be CORRECTLY and COMPREHENSIVELY and PROPERLY addressed.
    Fixing symptoms? That is only moving the brick wall a bit further away. Allowing you to run even faster into it the next time around.

  • 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)

  • I hate oracle support - transporting index tablespaces

    i exported 9 index tablespaces and ran the import into a database created as a duplicate of the original database (duplicated using RMAN). None of the indexes got created...yes I checked dba_segments.
    I am using 9iR2.
    Any suggestions?

    the intent was to bring over the 9 data tablespaces and the 9 index tablespaces using transportable tablespace -- the amount of data here is 2.5+ Tb. we exported the metadata for all 18 tablespaces and then tried to import that metadata to the new instance. the data came over fine but the indexes are non-existent. oracle support says this should have worked, but surprise, it didn't. it will take 72 hours or more to rebuild the indexes if we have to do it manually, which is why we trying to use transport to begin with. just copying all the files over took 20 hours.
    oracle says my indexes should be there. anyone else try to do this and what did they do to make it happen?

  • How to ignore index during impdp...

    Hi All,
    I have Oracle 11g database, I want to import one schmea;s tables into 11g database. Table is having 2 millons records and table size is 54G.
    During impdp this will definately take long time. As we had ignore=y and create index file option with IMP, do we have similar kind of thing with impdp?
    If you have any idea then please suggest me.
    Thanks in advance.

    Hi ,
    your suggested link and exclude option helps me.
    I have one query , in my impdp if I mentioned exclude parameter like exclude=INDEX:IN('TESTEMP') , then will it exlude only TESTEMP table's index or entire schema's index?
    my entire impdp command like below:
    impdp system/********@testqa remap_schema=SCOTT:SCOTT dumpfile=SCOTT.dmp TABLE_EXISTS_ACTION=SKIP
    exclude=INDEX:IN('TESTEMP') logfile=SCOTT_!.log directory=DATA_PUMP_DIR
    when this dump is running I observed that it was taking too much time on this line "SCHEMA_EXPORT/TABLE/INDEX/INDEX"...so I though it create indexes for all the tables except which I exclude in command.
    Please suggest me.
    Thanks...

  • Index, Hints, etc

    All,
    I was wondering whether you could please help out on the following points:
    (a) In the query below, what might be the suitable (and why?) indexes to be built?
    =======================================
    SELECT CONTRACT_PAY_GROUPS.CPG_AMOUNT_CY_AP,
    CONTRACT_PAY_GROUPS.CPG_AMOUNT_EU_AP,
    CONTRACT_PAY_GROUPS.CPG_TOTAL_ELIGIBLE_AREA
    FROM CONTRACT JOIN CONTRACT_PAY_GROUPS ON CONTRACT.AC_SEQ = CONTRACT_PAY_GROUPS.CPG_CON_SEQ
    WHERE CONTRACT.AC_START_YEAR = 2005
    AND CONTRACT.AC_APPLICANT_NUMBER = '50614'
    AND CONTRACT_PAY_GROUPS.CPG_SCHEME = 'Ε'
    AND CONTRACT.AC_STATUS <> 2
    =======================================
    (b) Can the query below be (re-)written in any better way, in terms of performance (that is, which ---type of--- indexes and/or hints might be important to be created)?
    =======================================
    SELECT LYALLPLOTS.CP_END_YEAR
    FROM (SELECT TYPLOTS.CP_PE_PLOT_ID FROM (SELECT CP_PE_PLOT_ID,
    CP_PE_PT_SEQ,
    AC_APPLICANT_NUMBER,
    AC_START_YEAR,
    AC_END_YEAR,
    AC_STATUS,
    AC_TYPE
    FROM CONTRACT JOIN CONTRACT_PLOT ON CONTRACT.AC_SEQ = CONTRACT_PLOT.CP_CON_SEQ
    JOIN APPLICATIONS ON CONTRACT.AC_APPL_SEQ = APPLICATIONS.APPL_SEQ
    WHERE APPLICATIONS.APPL_YEAR = 2005
    AND CP_PE_PT_SEQ IS NOT NULL ) TYPLOTS JOIN
    (SELECT PT_SEQ, PT_PLOT_ID, PT_FROM_APPL_NUM, PT_TO_APPL_NUM FROM PLOTS_TRANSFER) TRPLOTS
    ON TYPLOTS.CP_PE_PT_SEQ = TRPLOTS.PT_SEQ) TYTRANSFERS
    JOIN (SELECT CP_PE_PLOT_ID, AC_APPLICANT_NUMBER, CONTRACT_PLOT.CP_END_YEAR FROM CONTRACT_PLOT JOIN CONTRACT
    ON CONTRACT_PLOT.CP_CON_SEQ = CONTRACT.AC_SEQ
    WHERE CONTRACT.AC_START_YEAR = 2004) LYALLPLOTS ON TYTRANSFERS.CP_PE_PLOT_ID = LYALLPLOTS.CP_PE_PLOT_ID
    WHERE TYTRANSFERS.CP_PE_PLOT_ID = '5101-53/16--143'
    GROUP BY LYALLPLOTS.CP_END_YEAR;
    =======================================
    (c) In general, could you please provide any insight on which types of indexes and/or hints (UNNEST, HASH_AJ, etc) might be needed in the case we are joining tables?
    Any clue/support will be greatly appreciated. Thank you,
    -Pericles Antoniades.

    I'll echo sven's advice about not using hints unless you need to. I'm not telling you not to use hints. I am telling you to explore other solutions first, for the reasons sven mentioned.
    An indexing strategy can be tricky to come up with. There are guidelines to follow (which follow), but also exceptions to those guidelines. Your own observations may differ from I'm going to describe. Also, I only glanced at your posting and possibly missed something. I'm going to describe btree indexes. Bitmap indexes work a bit differently.
    Generally, indexes help do two things: get back small amounts of data quickly, and enforce uniqueness. Small amounts of data is sometimes considered to be between 15-20% of the rows in a table in 9i/10g; more than this and you might be better off with direct table access. Indexed lookups work well with nested loops joins (this is where the execution plan becomes useful) or direct table access, while other join methods (usually hash joins) may be more efficient when joining most of the rows from two tables.
    What columns should you index? That's a matter of some debate. You can search OTN for other ideas. The best candidates for indexing are columns used in your WHERE clauses and/or those that make up a unique key. In your example
    ON CONTRACT.AC_SEQ = CONTRACT_PAY_GROUPS.CPG_CON_SEQ WHERE CONTRACT.AC_START_YEAR = 2005 AND CONTRACT.AC_APPLICANT_NUMBER = '50614' AND CONTRACT_PAY_GROUPS.CPG_SCHEME = 'Ε' AND CONTRACT.AC_STATUS <> 2
    I personally get the best results by listing the indexes in the order of most to last restrictive, but that's a matter of some debate.
    I would consider putting indexes on contract.ac_seq, contract.ac_start_year contract.ac_applicant_number, and contrct.ac_status (composite), as well as contract_pay_groups.cpg_scheme and cpg_con_seq (composite). Then I would check to see if they were being used from an execution plan, ultimately using timings and run statistics from SQL*PLUS AUTOTRACE to decide if they were helping.

  • How do I get Oracle Text to index files on a file server?

    I am new to Oracle (I'm a MS-SQL DBA looking for a Full-Text Search solution that is better than linking to a MS index server.)
    So - Here's the objective:
    I have Oracle Server(Express) installed on a Windows server.
    I would like for Oracle to build a Full-Text Catalog of the files on a separate file server based on file paths in a table in the database.
    (No desire to store terabytes of images and documents inside the database)
    I can get Oracle text up and running, using the URL_Datastore:
    CREATE TABLE files (id NUMBER PRIMARY KEY, issue_id NUMBER, path VARCHAR(255) UNIQUE, ot_format VARCHAR(6), ot_version VARCHAR(10));
    The Compaq server is a remote windows server on my local workgroup, so the fully qualified path is just "compaq" and the URL is valid:
    INSERT INTO files VALUES (9,9,'file://Compaq/FTQ/00000003.pdf',NULL,NULL);
    INSERT INTO files VALUES (13,13,'file://Compaq/FTQ/01.txt',NULL,NULL);
    CREATE INDEX file_index ON files(path) INDEXTYPE IS ctxsys.context
    PARAMETERS ('datastore ctxsys.URL_DATASTORE format column ot_format');
    but when I enter:
    Select * from CTX_User_Index_errors, I see the following errors:
    DRG-11609: URL store: unable to open local file specified by file://Compaq/FTQ/00000003.pdf
    DRG-11609: URL store: unable to open local file specified by file://Compaq/FTQ/01.txt
    Did I miss something?
    Do I need to install anything on the file server?
    I would like to convince my company that Oracle can be much quicker than Microsoft's Indexing Service because it can avoid joining two large result sets (one result set from Full_text (indexing service) and one for specific data contained in fields in the MS-SQL database.) Full Text Searches commonly take 40 - 60 seconds where there are 1.5 million multi-page PDF files for a particular set that I sample search on. Without this massive join, I believe I can get the search to run in under 10 seconds.

    Thank you!
    File_Datastore worked fine.
    I was staying away from File_Datastore because the information I gathered from googling suggested that file_datastore would only work locally.
    Now I just have to get Oracle to pull data out of tables in a MS-SQL database on the local network (don't have a clue yet), and then have it index compiled file paths.
    Then MS-SQL can query Oracle with index and full-text criteria and Oracle can send back a result set
    It may sound like a bad way of performing Full-Text Queries, but anything will be better than the way things are currently running. We are currently performing Full Text Searches on a table that is rebuilt nightly, so the table containing millions of file paths is not live..
    It would be so much better if we just migrated to Oracle, but we currently do not have the resources.

  • Error while running the Oracle Text optimize index procedure (even as a dba user too)

    Hi Experts,
    I am on Oracle on 11.2.0.2  on Linux. I have implemented Oracle Text. My Oracle Text indexes are fragmented but I am getting an error while running the optimize_index error. Following is the error:
    begin
      ctx_ddl.optimize_index(idx_name=>'ACCESS_T1',optlevel=>'FULL');
    end;
    ERROR at line 1:
    ORA-20000: Oracle Text error:
    ORA-06512: at "CTXSYS.DRUE", line 160
    ORA-06512: at "CTXSYS.CTX_DDL", line 941
    ORA-06512: at line 1
    Now I tried then to run this as DBA user too and it failed the same way!
    begin
      ctx_ddl.optimize_index(idx_name=>'BVSCH1.ACCESS_T1',optlevel=>'FULL');
    end;
    ERROR at line 1:
    ORA-20000: Oracle Text error:
    ORA-06512: at "CTXSYS.DRUE", line 160
    ORA-06512: at "CTXSYS.CTX_DDL", line 941
    ORA-06512: at line 1
    Now CTXAPP role is granted to my schema and still I am getting this error. I will be thankful for the suggestions.
    Also one other important observation: We have this issue ONLY in one database and in the other two databases, I don't see any problem at all.
    I am unable to figure out what the issue is with this one database!
    Thanks,
    OrauserN

    How about check the following?
    Bug 10626728 - CTX_DDL.optimize_index "full" fails with an empty ORA-20000 since 11.2.0.2 upgrade (DOCID 10626728.8)

  • Oracle 9 spatial index export/import

    Hi,
    when exporting/importing a user via exp/imp I encounter a problem with the numeric characters encoding during creation of a spatial index.
    Imp tool produces script like this:
    "BEGIN "
    "execute immediate 'INSERT INTO USER_SDO_GEOM_METADATA values (''POINTS'',''GEOMETRY'',mdsys.SDO_dim_array(MDSYS.SDO_DIM_ELEMENT(''X'',50000000,160000000,,005),MDSYS.SDO_DIM_ELEMENT(''Y'',450000000,600000000,,005)),,005) ' ; "
    "COMMIT; END;"
    Problem is with wrong representation of the numeric value '0.005' as ,005.
    Originally, the index was created via
    INSERT INTO USER_SDO_GEOM_METADATA
    VALUES (
    'points',
    'geometry',
    MDSYS.SDO_DIM_ARRAY(
    MDSYS.SDO_DIM_ELEMENT('X',-125000000,-115000000, '0.005'),
    MDSYS.SDO_DIM_ELEMENT('Y', 30000000, 42100000, '0.005')
    NULL
    Any hints how to reimport the index correctly?
    Thanks,
    Bogart

    You might need to set the NLS_LANG environment variable to get character set conversion done on import (I don't know this unfortunately - it has never been a problem for me).
    There is a section on character set conversions in the utilities manual.

  • Suggestion: Oracle text CONTEXT index on one or more columns ?

    Hi,
    I'm implementing Oracle text using CONTEXT ..... and would like to ask you for performance suggestion ...
    I have a table of Articles .... with columns .. TITLE, SUBTITLE , BODY ...
    Now is it better from performance point of view to move all three columns into one dummy column ... with name like FULLTEXT ... and put index on this single column,
    and then use CONTAINS(FULLTEXT,'...')>0
    Or is it almost the same for oracle if i put indexes on all three columns and then call:
    CONTAINS(TITLE,'...')>0 OR CONTAINS(SUBTITLE,'...')>0 OR CONTAINS(BODY,'...')>0
    I actually don't care if the result is a match in TITLE OR SUBTITLE OR BODY ....
    So if i move into some FULLTEXT column, then i have duplicate data in a article row ... but if i create indexes for each column, than oracle has 2x more to index,optimize and search ... am I wright ?
    Table has 1.8mil records ...
    Thank you.
    Kris

    mackrispi wrote:
    Now is it better from performance point of view to move all three columns into one dummy column ... with name like FULLTEXT ... and put index on this single column,
    and then use CONTAINS(FULLTEXT,'...')>0What version of Oracle are you on? If 11 then you could use a virtual column to do this, otherwise you'd have to write code to maintain the column which can get messy.
    mackrispi wrote:
    Or is it almost the same for oracle if i put indexes on all three columns and then call:
    CONTAINS(TITLE,'...')>0 OR CONTAINS(SUBTITLE,'...')>0 OR CONTAINS(BODY,'...')>0Benchmark it and find out :)
    Another option would be something like this.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:9455353124561
    Were i you, i would try out those 3 approaches and see which meet your performance requirements and weigh that with the ease of implementation and administration.

Maybe you are looking for