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.

Similar Messages

  • 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

  • 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

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

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

  • How to import tables, indexes, tablespace, etc from a DMP.

    Hello,
    I like to know how to import tables, indexes, tablespace, etc from an DMP export of a Oracle 10.2.0.1 to be apply on a Oracle 11.2.0. When I import the DMP file all the data is going to one single Tablespace, for example, Users tablespace.
    On the original database we have various tablespace's each separated with different content (tables, indexes) and I like to know if it posible to import the same schema,tables, indexes, tablespace all made with one single DMP Export. I can't use DBUA because the software of the database on the 10.2 is missing, I have only a DMP file (24GB) of DMP!.
    Thanks for the reply,
    Sorry for my english :).
    Regards.

    thanks for that but is not what Im looking for.
    Look, on my ORCL directory of the oracle 10.2 I have for example this:
    CONTROL01.CTL
    EXAMPLE01.DBF
    REDO01-1.LOG
    REDO01.LOG
    REDO02-2.LOG
    REDO02.LOG
    REDO03-3.LOG
    REDO03.LOG
    RMAN.DBF
    SYSAUX01.DBF
    SYSTEM01.DBF
    TEMP01.DBF
    UNDOTBS01.DBF
    USERS01.DBF
    TABLESPACE1.ORA
    TABLESPACE2.ORA
    TABLESPACE3.ORA
    TABLESPACE4.ORA
    TABLESPACE5.ORA
    I make a full export to a DMP. Then in my 11.2 version first I created the user then when import the DMP file none of the tablespace (TABLESPACE1, TABLESPACE2, ETC...) is created, all is going to the USERS tablespace, SO, im looking a way to tell imp command that generates the exactly tablespace structure that i was have on the 10.2.
    Hope this can explain more my problem.
    Thanks again!.

  • MS 2000 Sql Index Hint In CFC Query

    How do you force the query in your function (component) to
    use the Index created. If you have some thing like this
    select *
    from class
    and a bunch of where clauses.
    Does CF allow for hints in the CFC's queries? any example?

    First it should automatically select the index. I would run
    it through query analyzer and see the exectution path. If you want
    to force and index..
    select * from class with INDEX(index1,index2..)

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

  • Use of Index, Histograms, etc

    Hi all,
    We're using Oracle 9.2.04.
    I have a table with 500000 rows.
    So I have a query that returns only 30242 for a month, like:
    SELECT * FROM T1
    WHERE TO_CHAR(DT, 'MM/YYYY') = TO_CHAR(ADD_MONTHS(SYSDATE, -1), 'MM/YYYY')
    I have a index for this column:
    CREATE INDEX IND_T1_DT_FMT ON T1 (TO_CHAR(DT, 'MM/YYYY'))
    TABLESPACE TBS_SOME_USER;
    There are statistics for this table.
    Looking the table data, I have the following distribution:
    Qty     MON/YY  %
    1         Feb-09     0.000219142
    99         Apr-09     0.021695016
    38439     May-09     8.42358314
    98231     Jun-09     21.52649641
    1         Jul-06     0.000219142
    139959     Jul-09     30.6708362
    1         Aug-02     0.000219142
    1         Aug-07     0.000219142
    141362     Aug-09     30.97829184
    30242     Sep-09      6.62727962
    7990              1.750941213But when a perform the query (that returns 30242 rows - 6.63% of table):
    SELECT * FROM T1
    WHERE TO_CHAR(DT, 'MM/YYYY') = TO_CHAR(ADD_MONTHS(SYSDATE, -1), 'MM/YYYY')
    Oracle uses FTS:
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=432 Card=45633 Bytes
    =3011778)
    1 0 TABLE ACCESS (FULL) OF 'T1' (Cost=432 Card=45633 Bytes
    =3011778)
    So, Oracle should not use the index in this case?
    Is there any way to gather statistics for this table with a index based function?
    Something like this:
    EXECUTE DBMS_STATS.GATHER_TABLE_STATS(ownname => 'U1',
    tabname => 'T1', method_opt => 'FOR COLUMNS TO_CHAR(DT, ''MM/YYYY'')',
    cascade => true, degree => 4);
    How can I create histograms for this case?
    Or other solution, like Partition?
    thank you very much!!!!

    Always treat dates like dates.
    This
    SELECT * FROM T1
    WHERE TO_CHAR(DT, 'MM/YYYY') = TO_CHAR(ADD_MONTHS(SYSDATE, -1), 'MM/YYYY')Should be more like this:
    SELECT * FROM T1
    WHERE DT BETWEEN TRUNC(ADD_MONTHS(SYSDATE,-1),'MM') AND TRUNC(SYSDATE,'MM')-1 ;Then you should index DT.
    But, should this query use the index?
    Touch and go at 6.63%.
    Give it a go using dates as dates and see if it makes a difference.
    Is there a problem with the performance of the FTS?

  • Expdp table  with grants indexes constraints etc

    hi
    i need to export table/sometime table partitions including grants, constraints, indexes
    this is what im using..
    expdp   parfile=par.exp directory=expdir dumpfile=exp1.dmp tables=hr.employee
    parfile.exp is:
    userid="/ as sysdba"
    JOB_NAME=dbajob
    do i need to include more options?
    thanks in advance

    Hi. As i know the indexes and the constraints need to be created with a different name.
    Try DBMS_METADATA.get_ddl to export your constraints and indexes.

  • How to make an index use in a query execution

    Hi,
    I have the below query for which ename column has an index. As of my knowledge below queries 1st and 2st will not use index. Hence i used the 3rd statement and that too its not using the index. Finally i used the 4th query, but even the 4th query is not using the index. Then how do i make this query to use my index??? Do i need to create a function based index for this??? Is that the final option????
    1. select * from emp where ename !='BH' ;
    2. select * from emp where ename <> 'BH';
    3. select * from emp where ename not in ('BH');
    4. select * from emp where ename < 'BH' or ename > 'BH';
    Regards,
    007
    Edited by: 007 on Jun 6, 2013 7:56 AM
    Edited by: 007 on Jun 6, 2013 8:06 AM
    Edited by: 007 on Jun 6, 2013 8:06 AM
    Edited by: 007 on Jun 6, 2013 8:06 AM
    Edited by: 007 on Jun 6, 2013 8:12 AM

    Sorry 007, I really thought you were posting a trick question as on the OCP tests.
    Anyway, as Justin mentioned, if you have an index on ename, it may be used when doing a comparison predicate statement with the ename value.
    What it depends on are several other things: stats, how many rows in the table, use of an index hint, etc.
    Rather than questioning the group on this, why not just turn on autotrace and run the query for the different scenarios.
    The output will show you if it used the index, number of rows returned, blocks read, etc.
    SQL> create table emp (ename  varchar2(40));
    Table created.
    SQL> insert into emp select username from sys.dba_users;
    25 rows created.
    SQL> commit;
    Commit complete.
    SQL> set autotrace on
    SQL> select * from emp where ename != 'SYSTEM';
    Execution Plan
    Plan hash value: 2951343571
    | Id  | Operation        | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT |           |    24 |   528 |     1   (0)| 00:00:01 |
    |*  1 |  INDEX FULL SCAN | ENAME_IDX |    24 |   528 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("ENAME"<>'SYSTEM')As you can see, the above used an index, even though there were only 25 rows in the table.
    You can test each of your scenarios, one by one, including use of a hint.

  • How to make an index in InDesign CC 2014.1 using a topics list?

    Hi all,
    I have read the long help document on how to make an index in InDesign CC 2014.1 using a topics list, and still can't work out what to do.
    I have done a 548 page book, using a document for each chapter, and a book file to put them all together in the right order.
    I now need to make an index at the back, as the author has many quotes throughout the book at the start of each chapter and section.
    I have a list of those people quoted and want to upload this list and get the index feature in InDesign to find all instances of the name occurring in the entire book.
    After reading the help document I still cannot work out how to do this.
    My questions are:
    1. Do you have to use an InDesign document as a source for the list of topics? If so, should the document be added to the book file or outside it?
    It seems a bit recursive to have the list of topics in an ID document that is in the book file.
    2. Once you have uploaded the topics into the Index feature, how do you get it to look for all instances of that 'topic' througout the entire book? I can't figure that out from the help documents. What do I select? Do I do it from the Index panel? Do I highlight the text in the source document? Not sure how to do this...
    3. I need the names to list surname first of the quoted authors in the index. This command seems to be different between various editions of ID. For ID CC 2014.1 is it ctrl+alt+shift+]
    4. To make the surname show first, what do I highlight? The topic? and then do ctrl+alt+shift+] and select find all as well? Or do I have to just go through the text and manually do this and ditch the idea of uploading topics first?
    I am confused as you can see and any help with this is appreciated.

    Sorry 007, I really thought you were posting a trick question as on the OCP tests.
    Anyway, as Justin mentioned, if you have an index on ename, it may be used when doing a comparison predicate statement with the ename value.
    What it depends on are several other things: stats, how many rows in the table, use of an index hint, etc.
    Rather than questioning the group on this, why not just turn on autotrace and run the query for the different scenarios.
    The output will show you if it used the index, number of rows returned, blocks read, etc.
    SQL> create table emp (ename  varchar2(40));
    Table created.
    SQL> insert into emp select username from sys.dba_users;
    25 rows created.
    SQL> commit;
    Commit complete.
    SQL> set autotrace on
    SQL> select * from emp where ename != 'SYSTEM';
    Execution Plan
    Plan hash value: 2951343571
    | Id  | Operation        | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT |           |    24 |   528 |     1   (0)| 00:00:01 |
    |*  1 |  INDEX FULL SCAN | ENAME_IDX |    24 |   528 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("ENAME"<>'SYSTEM')As you can see, the above used an index, even though there were only 25 rows in the table.
    You can test each of your scenarios, one by one, including use of a hint.

  • Interpreting the Explain plan

    DB version : 10.2.0.4
    After looking for Full Table Scan (in Large tables) , what is the next thing i should be looking for in an Explain Plan?

    Take the explain plan as an idea a tourist has to collect a bunch of stuff in your hometown. You ( as a local guy) will see quite quickly if the idea of collecting everything on the main routes in big shops by car (hash join) or doing a walk in one or two streets with small shops (nested loop) will perform better. Stangers will not.
    ORACLE already knows more about the data than a tourist about your hometome, so if it uses a method which is "suboptimal" it needs someone with good knowlage about the data to do better. So make sure you know your datamodel, contents, indexes, data and then you can help ORACLE with additional indexes, hints etc. without knowlege every plan of ORACLE can not be juged.

  • Minimize calls to the database..

    Im trying to find out what would be the best way to minmize calls to the database..
    I created a function that has to determine if a record exist on a table..
    There is a cursor that loops thru another table to see if the value exist on other tables.. .. and the function is called in every loop.. but that means that it has to make a trip to the database every time..
    Is there is anything like in .net datatable that i can load the entire table in memory (80.000 + records) and query from memory without having to go to the database every time ? Or is it acceptable to call the function in each loop ?
    What are the tradeoff's ?
    Thanks !!!

    for stuff like this, it really depends what your bottle neck is.
    if you are finding that the CPU is sitting at < 20% while your hard drive is spinning like mad, then investigate using collections (aka:associative arrays aka: pl/sql tables). to a bit of reading there's heaps of stuff out there, basic format:
    declare
    type type_foo is table of tbl_foo%rowtype index by binary integer;
    tab_foo type_foo;
    begin
    select * from tbl_foo bulk collect into tab_foo;
    --you can then refference each row in the collection by:
    for i in 1..100 loop
    dbms_output.put_line(tab_foo(i).foobar);
    end loop; --this will output the first 100 foobar's.
    --alternatively, if you have a number as a unique identifier in the table,
    --you can use that as the table index and check for existance like the following:
    if tab_foo(i).exists then
    --stuff
    end if;
    end;
    (disclaimer: the above was just off the top of my head - syntax may be slightly incorrect, RTM)
    this puts the whole table in memory.
    now if after doing this, you find that your cpu is sitting at 100% and your hard drive is barely spinning, then you've potentially not solved your problem. check how long it takes - if one is not significantly faster than the other, then investigate other ways of speading it up (indexes, hints etc.)
    if you use a collection and you get 100% memory usage AND your hard drive is spinning like crazy, you've perhaps used too much memory and the server's using the swap file, defeating the purpose of putting something in memory in the first place.
    anyway, try it and see :D

  • Index is not getting picked even after providing hint

    Hi All
    The index pk_sku is not getting picked even after providing the hints when executing the query.Please kindly give me such recommendations.I am providing the information.
    select  * from
    (select /*+ index(s pk_sku) */
          to_char(t.dstamp, 'YYYYmmDDHH24MI') as sort_1,
          t.client_id as CLIENT_ID ,
          t.site_id as SITE_ID,
          tz.time_zone_name as TIME_ZONE_NAME     ,
          t.owner_id as OWNER_ID,
          t.sku_id as SKU_ID,
          t.reason_id as ADJUST_TYPE,
          to_char(t.dstamp+tz.diff/24, 'DD/mm/YYYY HH24:MI') as ADJUST_DATETIME,
          t.reference_id as RECEIPT_ID,
          t.batch_id as BATCH_ID,
          t.update_qty as UPDATE_QTY,
          t.lock_code as LOCK_CODE,
          s.description as SKU_DESCRIPTION
    from  mv_inventory_transaction t
          JOIN timezone tz ON tz.site_id = t.site_id ,
           mv_sku s
    where   t.sku_id= s.sku_id
    and     t.client_id=s.client_id
    and   ( :client is null or :client = t.client_id)
    and    ( :site is null or t.site_id  in (:site))
    and    ( :owner is null or t.owner_id in (:owner))
    and    t.code= 'Adjustment'
    and   (t.dstamp+tz.diff/24) between  to_date(:dateFrom, 'DD/mm/yyyy') and to_date(:dateTo,'DD/mm/yyyy')+1
    and      (:sku is null or t.sku_id in (:sku))
    UNION ALL
    (select  /*+ index(s pk_sku) */
         to_char(t.dstamp, 'YYYYmmDDHH24MI') as sort_1,
        t.client_id as CLIENT_ID ,
          t.site_id as SITE_ID,
                          tz.time_zone_name as TIME_ZONE_NAME     ,
          t.owner_id as OWNER_ID,
          t.sku_id as SKU_ID,
          t.reason_id as ADJUST_TYPE,
          to_char(t.dstamp+tz.diff/24, 'DD/mm/YYYY HH24:MI') as ADJUST_DATETIME,
          t.reference_id as RECEIPT_ID,
          t.batch_id as BATCH_ID,
          t.update_qty as UPDATE_QTY,
          t.lock_code as LOCK_CODE,
          s.description as SKU_DESCRIPTION
    from  mv_inventory_transaction_arch t
          JOIN timezone tz ON tz.site_id = t.site_id,
           mv_sku s
    where   t.sku_id= s.sku_id
    and     t.client_id=s.client_id
    and   ( :client is null or :client = t.client_id)
    and    ( :site is null or t.site_id  in (:site))
    and    ( :owner is null or t.owner_id in (:owner))
    and    t.code= 'Adjustment'
    and   (t.dstamp+tz.diff/24) between  to_date(:dateFrom, 'DD/mm/yyyy') and to_date(:dateTo,'DD/mm/yyyy')+1
    and      (:sku is null or t.sku_id in (:sku))
    order by sort_1,2,3,4,5
    version = Release 10.1.0.5.0
    SQL> sho parameter optimizer
    NAME                                 TYPE        VALUE
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      10.1.0.5
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      ALL_ROWS
    sho parameter db_file_multiblock_count_read
    sho parameter cursor_sharing
    SQL> sho parameter optimizer
    NAME                                 TYPE        VALUE
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      10.1.0.5
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      ALL_ROWS
    SQL>  sho parameter db_file_multi
    NAME                                 TYPE        VALUE
    db_file_multiblock_read_count        integer     16
    SQL> sho parameter cursor_sharing
    NAME                                 TYPE        VALUE
    cursor_sharing                       string      EXACTExplain plan
    | Id  | Operation                              | Name                          | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                       |                               |    56 | 29736 |   345K  (1)| 01:09:07 |
    |   1 |  SORT ORDER BY                         |                               |    56 | 29736 |   345K  (1)| 01:09:07 |
    |   2 |   VIEW                                 |                               |    56 | 29736 |   345K  (1)| 01:09:07 |
    |   3 |    UNION-ALL                           |                               |       |       |            |          |
    |   4 |     NESTED LOOPS                       |                               |     2 |   984 | 29686   (1)| 00:05:57 |
    |   5 |      HASH JOIN                         |                               |     1 |   326 | 26870   (1)| 00:05:23 |
    |   6 |       TABLE ACCESS FULL                | TIMEZONE                      |     4 |    88 |     3   (0)| 00:00:01 |
    |   7 |       VIEW                             | MV_INVENTORY_TRANSACTION      |    25 |  7600 | 26866   (1)| 00:05:23 |
    |   8 |        UNION-ALL                       |                               |       |       |            |          |
    |   9 |         FILTER                         |                               |       |       |            |          |
    |  10 |          MAT_VIEW ACCESS BY INDEX ROWID| MV_INVENTORY_TRANSACTION      |     1 |    67 | 24327   (1)| 00:04:52 |
    |  11 |           INDEX RANGE SCAN             | IDX_CODE_CLIENTID_690         | 79681 |       |   518   (1)| 00:00:07 |
    |  12 |         FILTER                         |                               |       |       |            |          |
    |  13 |          MAT_VIEW ACCESS BY INDEX ROWID| MV_INVENTORY_TRANSACTION      |    24 |  2328 |  2539   (1)| 00:00:31 |
    |  14 |           INDEX RANGE SCAN             | IDX_CODE_646                  |  9269 |       |    46   (0)| 00:00:01 |
    |  15 |      VIEW                              | MV_SKU                        |    37 |  6142 |  2816   (1)| 00:00:34 |
    |  16 |       UNION-ALL                        |                               |       |       |            |          |
    |  17 |        MAT_VIEW ACCESS FULL            | MV_SKU                        |   335K|    10M|  2535   (1)| 00:00:31 |
    |  18 |        MAT_VIEW ACCESS FULL            | MV_SKU                        | 37839 |  1699K|   280   (1)| 00:00:04 |
    |  19 |     NESTED LOOPS                       |                               |    54 | 26568 |   315K  (1)| 01:03:10 |
    |  20 |      HASH JOIN                         |                               |     1 |   326 |   313K  (1)| 01:02:37 |
    |  21 |       TABLE ACCESS FULL                | TIMEZONE                      |     4 |    88 |     3   (0)| 00:00:01 |
    |  22 |       VIEW                             | MV_INVENTORY_TRANSACTION_ARCH |   576 |   171K|   313K  (1)| 01:02:37 |
    |  23 |        UNION-ALL                       |                               |       |       |            |          |
    |  24 |         FILTER                         |                               |       |       |            |          |
    |  25 |          MAT_VIEW ACCESS BY INDEX ROWID| MV_INVENTORY_TRANSACTION_ARCH |     1 |    72 | 19258   (1)| 00:03:52 |
    |  26 |           INDEX RANGE SCAN             | QUI_IDX_INVTRANS_ARC1         | 36016 |       |   287   (1)| 00:00:04 |
    |  27 |         FILTER                         |                               |       |       |            |          |
    |  28 |          MAT_VIEW ACCESS BY INDEX ROWID| MV_INVENTORY_TRANSACTION_ARCH |   575 | 55200 |   293K  (1)| 00:58:45 |
    |  29 |           INDEX RANGE SCAN             | QUI_IDX_INVTRANS_ARC1         |   367K|       |  3466   (1)| 00:00:42 |
    |  30 |      VIEW                              | MV_SKU                        |    37 |  6142 |  2816   (1)| 00:00:34 |
    |  31 |       UNION-ALL                        |                               |       |       |            |          |
    |  32 |        MAT_VIEW ACCESS FULL            | MV_SKU                        |   335K|    10M|  2535   (1)| 00:00:31 |
    |  33 |        MAT_VIEW ACCESS FULL            | MV_SKU                        | 37839 |  1699K|   280   (1)| 00:00:04 |
    ------------------------------------------------------------------------------------------------------------------------when put in sql tuning advisor,It recommended with better plan using indexes
    | Id  | Operation                              | Name                          | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                       |                               |    56 | 29736 |   340K  (1)| 01:08:01 |
    |   1 |  SORT ORDER BY                         |                               |    56 | 29736 |   340K  (1)| 01:08:01 |
    |   2 |   VIEW                                 |                               |    56 | 29736 |   340K  (1)| 01:08:01 |
    |   3 |    UNION-ALL                           |                               |       |       |            |          |
    |   4 |     NESTED LOOPS                       |                               |     2 |   848 | 26900   (1)| 00:05:23 |
    |   5 |      HASH JOIN                         |                               |     1 |   326 | 26898   (1)| 00:05:23 |
    |   6 |       TABLE ACCESS FULL                | TIMEZONE                      |     4 |    88 |     3   (0)| 00:00:01 |
    |   7 |       VIEW                             | MV_INVENTORY_TRANSACTION      |    25 |  7600 | 26894   (1)| 00:05:23 |
    |   8 |        UNION-ALL                       |                               |       |       |            |          |
    |   9 |         FILTER                         |                               |       |       |            |          |
    |  10 |          MAT_VIEW ACCESS BY INDEX ROWID| MV_INVENTORY_TRANSACTION      |     1 |    67 | 24352   (1)| 00:04:53 |
    |  11 |           INDEX RANGE SCAN             | IDX_CODE_CLIENTID_690         | 79681 |       |   518   (1)| 00:00:07 |
    |  12 |         FILTER                         |                               |       |       |            |          |
    |  13 |          MAT_VIEW ACCESS BY INDEX ROWID| MV_INVENTORY_TRANSACTION      |    24 |  2328 |  2542   (1)| 00:00:31 |
    |  14 |           INDEX RANGE SCAN             | IDX_CODE_646                  |  9269 |       |    46   (0)| 00:00:01 |
    |  15 |      VIEW                              | MV_SKU                        |    37 |  3626 |     2   (0)| 00:00:01 |
    |  16 |       UNION-ALL PARTITION              |                               |       |       |            |          |
    |  17 |        MAT_VIEW ACCESS BY INDEX ROWID  | MV_SKU                        |     1 |    34 |     3   (0)| 00:00:01 |
    |  18 |         INDEX UNIQUE SCAN              | PK_SKU                        |     1 |       |     2   (0)| 00:00:01 |
    |  19 |        MAT_VIEW ACCESS BY INDEX ROWID  | MV_SKU                        |     1 |    46 |     2   (0)| 00:00:01 |
    |  20 |         INDEX UNIQUE SCAN              | PK_SKU                        |     1 |       |     1   (0)| 00:00:01 |
    |  21 |     NESTED LOOPS                       |                               |    54 | 22896 |   313K  (1)| 01:02:38 |
    |  22 |      HASH JOIN                         |                               |     1 |   326 |   313K  (1)| 01:02:38 |
    |  23 |       TABLE ACCESS FULL                | TIMEZONE                      |     4 |    88 |     3   (0)| 00:00:01 |
    |  24 |       VIEW                             | MV_INVENTORY_TRANSACTION_ARCH |   576 |   171K|   313K  (1)| 01:02:38 |
    |  25 |        UNION-ALL                       |                               |       |       |            |          |
    |  26 |         FILTER                         |                               |       |       |            |          |
    |  27 |          MAT_VIEW ACCESS BY INDEX ROWID| MV_INVENTORY_TRANSACTION_ARCH |     1 |    72 | 19269   (1)| 00:03:52 |
    |  28 |           INDEX RANGE SCAN             | QUI_IDX_INVTRANS_ARC1         | 36016 |       |   287   (1)| 00:00:04 |
    |  29 |         FILTER                         |                               |       |       |            |          |
    |  30 |          MAT_VIEW ACCESS BY INDEX ROWID| MV_INVENTORY_TRANSACTION_ARCH |   575 | 55200 |   293K  (1)| 00:58:47 |
    |  31 |           INDEX RANGE SCAN             | QUI_IDX_INVTRANS_ARC1         |   367K|       |  3466   (1)| 00:00:42 |
    |  32 |      VIEW                              | MV_SKU                        |    37 |  3626 |     2   (0)| 00:00:01 |
    |  33 |       UNION-ALL PARTITION              |                               |       |       |            |          |
    |  34 |        MAT_VIEW ACCESS BY INDEX ROWID  | MV_SKU                        |     1 |    34 |     3   (0)| 00:00:01 |
    |  35 |         INDEX UNIQUE SCAN              | PK_SKU                        |     1 |       |     2   (0)| 00:00:01 |
    |  36 |        MAT_VIEW ACCESS BY INDEX ROWID  | MV_SKU                        |     1 |    46 |     2   (0)| 00:00:01 |
    |  37 |         INDEX UNIQUE SCAN              | PK_SKU                        |     1 |       |     1   (0)| 00:00:01 |
    ------------------------------------------------------------------------------------------------------------------------So ,after checking the recommended plan I tried to execute the query with the hints,even then it is picking up the indexes in the explain plan.So please kindly help in solving the issue
    The pk_sku is the index created on client_id and sku_id columns
    Thanks
    GV

    riedelme wrote:
    My experience is differernt - hints will be followed if the optimizer determines they will be beneficial and not if they will not, including my current project on 11gR2. The example below (unfortunately only 11gR1) disproves your theory, showing the index hint is followed and that the cost increases by a factor of five.
    The most common cases of the optimizer apparently ignoring a hint are due to operator error, the hint is not well formed, or cannot be followed. There are a couple of documented cases where a hint will be ignored - first_rows used in CTAS is one.
    Jonathan Lewis writes a lot about it on his blog showing that the optimizer always acts on a well formed hint if it is at all possible.
    SQL> create table t (n number not null, c varchar2(1000));
    Table created.
    SQL> insert into t select 1, rpad('x',1000,'x')
      2  from dual connect by level <= 50000;
    50000 rows created.
    SQL> create index t_ix on t (n);
    Index created.
    SQL> exec dbms_stats.gather_table_stats(user, 't', cascade => true)
    PL/SQL procedure successfully completed.
    SQL> explain plan for
      2  select max(c) from t where n =1;
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 2966233522
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |     1 |  1004 |  1574   (1)| 00:00:19 |
    |   1 |  SORT AGGREGATE    |      |     1 |  1004 |            |          |
    |*  2 |   TABLE ACCESS FULL| T    | 50000 |    47M|  1574   (1)| 00:00:19 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       2 - filter("N"=1)
    14 rows selected.
    SQL> explain plan for
      2  select /*+ index (t t_ix) */  max(c) from t where n = 1;
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3231292748
    | Id  | Operation                    | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |      |     1 |  1004 |  7244   (1)| 00:01:27 |
    |   1 |  SORT AGGREGATE              |      |     1 |  1004 |            |          |
    |   2 |   TABLE ACCESS BY INDEX ROWID| T    | 50000 |    47M|  7244   (1)| 00:01:27 |
    |*  3 |    INDEX RANGE SCAN          | T_IX | 50000 |       |    98   (0)| 00:00:02 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       3 - access("N"=1)
    15 rows selected.

Maybe you are looking for

  • 'NAVIGATION_FILENAME_HELP + file_open_error

    hi there, I am making a BDC, i am supplying the input as a txt file using navigation_filename_help, now as soon as i open the f4 for the file name i get a file_open_error error. Can anyone please help. Regards

  • HP Officejet Pro 8500A constantly changing IP

    Hi, we have the HP Officejet Pro 8500A Plus e-All-in-One Printer - A910g, Model name: CM756A. We set it up in our peer to peer workgroup (non domain) Windows network wirelessly. But every time there is a need to reset the router (when we have interne

  • Screen Surround Issues

    About 4 weeks ago the left rubber bump that stops the screen touching the keyboard fell off my iBook, i tried super-glueing it on but i failed. I gave up. Now though i've just noticed a crack in the screen surround plastic - parallel to the edge of t

  • MP3 Player

    I am a begginer and have had a bit of help on this stuff but im am stuck. in brief, i have a class that loads xml, creates a list holder that dislplays the "items". I then have a listItem class that says when an item is clicked to dispatch a custom e

  • How to convert InDesign CS2 files for editing in CS5 (win)

    We are a small publishing company with several top-selling language products. I need to revision a title which was published 10 years ago. The files are CS2 and I cannot open them in CS5. Seem Adobe doesn't offer any conversion utility. It seem I nee