Performance Issue - Index is not used when a zero padded string is queried

Hi All,
I have a table T1 which has many columns. One such column say C1 is a varchar2(20). T1 has 10 million rows and there is an index called I1 on C1. Stats are current for both tables and indexes. These are the scenarios:
Scenario 1
select *   from T1 where C1 = '0013206263' --Uses index I1
187 ms
Scenario 2
select *   from T1 where C1 = '8177341863' --Uses index I1
203 ms
*Scenario 3*
*select *   from T1 where C1 = '0000000945' --Uses Fulll Table Scan --Very Slow*
*45 seconds*
When I force the sql to use the index through a hint, it is working fine:
Scenario 4
select /*+ INDEX (t1 i1) */  *   from T1 where C1 = '0013206263' --Uses index I1
123 ms
Scenario 5
select /*+ INDEX (t1 i1) */  *   from T1 where C1 = '8177341863' --Uses index I1
201 ms
*Scenario 6*
*select /*+ INDEX (t1 i1) */  *   from T1 where C1 = '0000000945' --Uses index I1*
*172ms*Is there any reason for this performance issue? Why does the optimizer goes for FTS in Scenario 3?
Edited by: user539954 on May 14, 2009 12:22 PM
Edited by: user539954 on May 14, 2009 12:32 PM

user539954 wrote:
Please see the replies below:
- How many distinct values for C1 out of that 10 million rows? I'm guessing that histograms were created for C1, correct?
=>7 million distinct c1 values. I have not gathered a histogram yet. Should I try that?
SQL> explain plan for select * from T1  where C1 = '0000000954';
| Id  | Operation         | Name           | Rows  | Bytes | Cost (%CPU)|
|   0 | SELECT STATEMENT  |                |   244K|    19M| 26228   (5)|
|   1 |  TABLE ACCESS FULL| T1 |   244K|    19M| 26228   (5)|
SQL> explain plan for select * from T1  where C1 = '0033454555';
| Id  | Operation                   | Name               | Rows  | Bytes | Cost (%CPU)|
|   0 | SELECT STATEMENT            |                    |   532 | 43624 |   261   (0)|
|   1 |  TABLE ACCESS BY INDEX ROWID| T1     |   532 | 43624 |   261   (0)|
|   2 |   INDEX RANGE SCAN          | I1 |   532 |       |     2   (0)|
It's possible you do have a histogram, even though you didn't plan on creating it, if you're running 10g.
In the absence of a histogram and with 7M distinct keys in 10M rows, Oracle should have predicted 2 rows for both queries, not 244,000 and 532.
If you do have a histogram, you probably need to get rid of it.
Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
http://www.jlcomp.demon.co.uk
"Science is more than a body of knowledge; it is a way of thinking"
Carl Sagan
To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • How can i know which index will be used when executing the query ?

    1 ) I have query in which i have 3-4 tables but there multiple index on one column .
    so how can i know which index will be used when executing the query ?
    2) I have a query which ia taking too much time . how can i know which table is taking too much time ?
    3) Please Provide me some document of EXplain plan ?

    Hi Jimmy,
    Consider the below example
    /* Formatted on 2011/02/04 21:59 (Formatter Plus v4.8.8) */
    CREATE TABLE FIRST AS
    SELECT * FROM all_objects;
    UPDATE FIRST
    SET object_name = 'TEST'
    WHERE owner != 'SCOTT';
    CREATE INDEX idx_first ON FIRST(object_name);
    SELECT *
    FROM FIRST
    WHERE object_name = 'TEST';
    It has not used index
    Execution Plan
    Plan hash value: 2265626682
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 58678 | 7334K| 163 (4)| 00:00:02 |
    |* 1 | TABLE ACCESS FULL| FIRST | 58678 | 7334K| 163 (4)| 00:00:02 |
    /* Formatted on 2011/02/04 21:59 (Formatter Plus v4.8.8) */
    SELECT *
    FROM FIRST
    WHERE object_name = 'emp';
    This has used the index
    Execution Plan
    Plan hash value: 1184810458
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 128 | 1 (0)| 00:00:01 |
    | 1 | TABLE ACCESS BY INDEX ROWID| FIRST | 1 | 128 | 1 (0)| 00:00:01 |
    |* 2 | INDEX RANGE SCAN | IDX_FIRST | 1 | | 1 (0)| 00:00:01 |
    From this we can come to the conclusion that, whether to use one index or not by oracle
    would also depend on the data which is present in the table. This has to be this way as
    we see in the bind peeking, if oracle sticks to only one plan, say only use the full table
    scan, it would be a performance hit when it searches for the second query ie where object_name
    ='emp';
    2.
    If we have a query like below.
    select * from emp
    where upper(ename) = upper(:p_ename);
    Evenif we have the index on ename column, oracle wouldn't be able to use the index, as there is a function in the predicate column. If you need oracle to use the index, we need to create a function based index as below.
    Create index idx_ename on emp(upper(ename));
    Regards,
    Cool

  • Custom hostname verifier not used when business services use a http proxy

    On OSB 10.3, we have a business services with an https end point. To access this end point, the business service used an http proxy.
    The certificate of the business endpoint is a wildcard certificate *.certificate.be . So we have a custom hostname verifier defined in the ssl configuration on the weblogic Server
    As we can see with the verbose mode at the jvm, the custom hostname verifier is not used when we use a http proxy in the business service. Osb use a ALSBHostnameVerifier and this one the defaulthostName
    <Mar 2, 2011 7:31:11 AM CET> <Debug> <AlsbTransports> <BEA-000000> <*** Connecting via proxy *** HTTP @ my.proxy.be/XXX.XXX.XXX.XXX:8080>
    [Loaded com.bea.wli.sb.transports.http.ALSBHostnameVerifier from file:/bea/osb_10.3/lib/sb-transports-main.jar]
    [Loaded weblogic.security.utils.SSLWLSHostnameVerifier$DefaultHostnameVerifier from file:/bea/wlserver_10.3/server/lib/weblogic.jar]
    Is there any way to force business service to used hostname verfifier defined in weblogic ssl server config?
    Thanks

    This is a known issue. Raise a case with support and ask a patch for bug#9182604
    Regards,
    Anuj

  • Why index is not used by this table

    Dear all,
    Currently I'm facing problem with tuning one sql statement.
    It shows that full table scan in ZTLTBC_FILTER cost 15:19.
    But in table ZTLTBC_FILTER, it have index with field
    index 1    MANDT INT_NAME FNAME VALUE
    index 2    MANDT EXEC_ID COUNTER
    index 3    MANDT INT_NAME VALUE
    the last statistic date for these index is three months before
    Could you please help to find out the reason why index is not used?  statistics are old or small distinct value for field INT_NAME?
    How to solve this full table scan problem?
    Thanks & Regards,
    Chris
    sql statement
    SELECT T_00."MANDT",T_00."EXEC_ID",T_00."COUNTER",T_00."FNAME",T_00."INT_NAME",T_00."VALUE"
    FROM "ZTLTBC_FILTER" T_00
    WHERE T_00."MANDT"=:A0 AND T_00."INT_NAME"=:A1 AND EXISTS
    (SELECT T_100."INT_NAME"
    FROM "ZTLTBC_MIRR_BUFF" T_100
    WHERE T_100."MANDT"=:A2 AND T_100."INT_NAME"=:A3 AND T_100."EXEC_ID"=T_00."EXEC_ID" AND
    T_100."COUNTER"=T_00."COUNTER")
    | Id  | Operation            | Name               | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |                    |       |       |       |   176K(100)|          |
    |*  1 |  HASH JOIN RIGHT SEMI|                    |  9958K|  1111M|   598M|   176K  (2)| 00:17:53 |
    |*  2 |   INDEX RANGE SCAN   | ZTLTBC_MIRR_BUFF~0 |  9958K|   484M|       |  6265   (1)| 00:00:39 |
    |*  3 |   TABLE ACCESS FULL  | ZTLTBC_FILTER      |    13M|   822M|       |   150K  (2)| 00:15:19 |
       1 - access("T_100"."EXEC_ID"="T_00"."EXEC_ID" AND "T_100"."COUNTER"="T_00"."COUNTER")
       2 - access("T_100"."MANDT"=:A2 AND "T_100"."INT_NAME"=:A3)
       3 - filter(("T_00"."INT_NAME"=:A1 AND "T_00"."MANDT"=:A0))

    Hello Bret,
    I'm using oracle 11.2
    Thanks & Regards,
    Chris

  • The sort field is not used when ordering multiple cds in one alumn folder, how do I correct this?

    It is using the track number and not the sort order field.  The reason I have multiple cds in one alumn is because they are books on cd.

    Sorry for the typo my "b" key was not working correctly.
    The sort field is not used when ordering multiple cds in one albumn folder, how do I correct this?  It is using the track number and not the sort order field.  The reason I have multiple cds in one albumn is because they are books on cd.

  • Performance issue - Index not being used

    Hi,
    I have the following scenario
    - I have a table Account with a PK -Account_ID, for which there is a index PK_ACCOUNT_ID_IDX
    - Another table Account_fact has a PK - Account_ID, Month_Year, for which there is a index PK_ACCOUNT_FACT_IDX
    I have a join in these two table. The query is
    select a.ACCOUNT_ID, b.Cost
    From Account a, Account_fact b
    Where a.account_id = b.Account_id
    and a.Include_flag = 'Y'
    The explain plan for this query tells me its doing a Full table scan and not using the index and the cost of query is very high.
    Can any one suggest what is wrong here.
    Regards
    Deepak

    >> Shud I be creating a bit map index.
    Bit map index is not for this case.
    http://download-east.oracle.com/docs/cd/B10501_01/server.920/a96533/data_acc.htm#8131
    Also bitmaps are very dangerous for Transactional tables. They are not meant for them.
    As I told you in this case create index on all the columns you are using in the query.
    For example INCLUDE_FLAG, ACCOUNT_ID in ACCOUNT table
    ACCOUNT_ID, COST in the other table.
    But keep in mind that if you are selecting any other column from these tables then again it might opt for full table scan......

  • Oracle 10.2.0.4 Index on timestamp column not used when SYSTIMESTAMP Used.

    Hi,
    I have a table A with a column B timestamp(6). The tables contains around 300000 rows..
    I have created index 'idx' on the column B.
    When i compare column 'B' with systimestamp, it does not use the index, whereas if i compare 'B' with sysdate it uses the index.
    Eg :
    select count(*) from a where b<=sysdate;
    The above used the index 'idx' and executed in 1 second
    select count(*) from a where b<=systimestamp;
    The above does not use the index and executed in 19 seconds.
    Any Clue?
    Thanks in Advance

    Oracle is using Internal functions when you use SYSTIMESTAMP:
    Work around will be to use TO_TIMESTAMP as shown below.. Or define a function based index..
    You can check performance problem querying against a "TIMESTAMP WITH TIME ZONE" column link also
    SQL> create table a(b timestamp(6));
    Table created.
    SQL> insert into a
      2  select systimestamp+(level/24) from dual connect by level <= 30000;
    30000 rows created.
    SQL> commit;
    Commit complete.
    SQL> create index ndx on a(b);
    Index created.
    SQL> explain plan for
      2  select count(*) from a where b <= sysdate;
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3858831102
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |    13 |     1   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE   |      |     1 |    13 |            |          |
    |*  2 |   INDEX RANGE SCAN| NDX  |     1 |    13 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("B"<=SYSDATE@!)
    Note
       - dynamic sampling used for this statement
    18 rows selected.
    SQL> explain plan for
      2  select count(*) from a where b <= systimestamp;
    Explained.
    SQL>  select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3918351354
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |     1 |    13 |    20  (15)| 00:00:01 |
    |   1 |  SORT AGGREGATE    |      |     1 |    13 |            |          |
    |*  2 |   TABLE ACCESS FULL| A    |     1 |    13 |    20  (15)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter(SYS_EXTRACT_UTC(INTERNAL_FUNCTION("B"))<=SYS_EXTRACT_UTC(S
                  YSTIMESTAMP(6)))
    Note
       - dynamic sampling used for this statement
    19 rows selected.
    --"Just tried using TO_TIMESTAMP"
    SQL> explain plan for
      2  select count(*) from a where b <= to_timestamp(systimestamp);
    Explained.
    SQL>
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3858831102
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |    13 |     2   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE   |      |     1 |    13 |            |          |
    |*  2 |   INDEX RANGE SCAN| NDX  |     4 |    52 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("B"<=TO_TIMESTAMP(TO_CHAR(SYSTIMESTAMP(6))))
    14 rows selected.Edited by: jeneesh on Oct 23, 2012 11:18 AM

  • Insane performance issue. GPU not being used at all for cropping.

    I regularly record my screen and later open the resulting file in Pr and export only a square on it. I import the video, maybe cut away some fluff, and export, choosing to crop it.
    The result is a painful ordeal that cripples my computer for hours every single day, where Premiere Pro CC uses almost 100% CPU constantly, but 0% of the GPU. It's really extremely slow. Other export tasks seem to be as quick as you expect them to be. But not this particular job, which I rely on every day. Very annoying.
    There is simply no way that this is intended. The GPU seems to be made for things like this. Why isn't Pr using it?
    I have 20 GB RAM, a very powerful quad core Xeon, a new Nvidia GPU, solid state disk, etc. Windows 8.1 Update 1. My computer is never slow for other tasks. This is really a very annoying issue as it makes using the computer nearly impossible for hours a day. For no good reason. It needs to use the graphics card to crop!

    It just really annoys me that this kind of thing is ever turned off, hidden away and just... ambiguous.
    Its hardly hidden away.  Its in the NEW PROJECT Settings page and first setting drop down option.
    There are reasons why its an option... buts its ON by default on any new project I start.

  • OSB Workshop Issue: Dependency is not configured when import xmlmime schema

    Hello,
    I use OSB workshop Version: 10.3 Build id: 1137967 and am little bit confused with following issue:
    I got some WSDL and XSD from 3rd party, these were prepared in Visual Studio, the XSD files include following import:
    <s:import namespace="http://www.w3.org/2005/05/xmlmime" schemaLocation="http://www.w3.org/2005/05/xmlmime"/>
    When I delete this line from schema everything is ok, when I left it in there i experience following error:
    The dependency is not configured in schema resource. Possible reason one or more import/include is not set correctly.     
    Here is sample:
    <?xml version="1.0" encoding="UTF-8"?>
    <s:schema xmlns="urn:dynn:lcr:portal:shooter:types"
    xmlns:s="http://www.w3.org/2001/XMLSchema"
    xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
    targetNamespace="urn:dynn:lcr:portal:shooter:types" elementFormDefault="qualified">
    <s:import namespace="http://www.w3.org/2005/05/xmlmime" schemaLocation="http://www.w3.org/2005/05/xmlmime"/>
    <s:complexType name="LangContentType">
    <s:sequence>
    <s:element name="Kategorie" maxOccurs="unbounded">
    <s:complexType>
    <s:simpleContent>
    <s:extension base="s:string">
    <s:attribute name="index" type="s:int" use="required"/>
    </s:extension>
    </s:simpleContent>
    </s:complexType>
    </s:element>
    </s:sequence>
    </s:complexType>
    When I delete the import line, the issue dissapears. Any hints? I also found out that the xmime namespace is not used in whole schema, so it seems to me like the Visual Studio just added some default namespace definition into schema at generation stage.
    Ladislav

    Please refer -
    The dependency is not configured in schema resource. Error in OEPE
    Regards,
    Anuj

  • Index is not used, although hint.

    DBVersion: 10.2.0.3
    CREATE TABLE "ESW"."DURCHLAUFZEIT_SONDER_AG"
       (     "AG" NUMBER(3,0) DEFAULT 0 NOT NULL ENABLE,
         "TAGE" NUMBER(5,0) DEFAULT 0 NOT NULL ENABLE,
         "ABTEILUNG" VARCHAR2(20 BYTE),
    Content of this table
    AG    TAGE  ABTEILUNG
    910     1     EAV
    133     1     TG
    743     2     TM
    719     2     TM
    706     2     TM
    979     10     TMWhen I use a select like this no index on tabel "walze w2" is used:
    select /*+ index(apl(arbeitsgang_nr))*/
           /*+ index(w2 WALZE_IND1)*/
            SUM (dsa.tage) tage,
             w2.walzen_nr walzen_nr,
            w2.walzen_ng walzen_ng
          from durchlaufzeit_sonder_ag dsa,
               auftrag_arbeitsplan apl,
               walze w2
          where apl.arbeitsgang_nr in
              ( select dsa1.ag ag
                from durchlaufzeit_sonder_ag dsa1
                where dsa1.abteilung = 'TM' )*and apl.auftr_nr = w2.auftr_nr
    and apl.auftr_jj = w2.auftr_jj
    and apl.auftr_pos = w2.auftr_pos
    and apl.auftr_los = w2.auftr_los
    and dsa.abteilung = 'TM'
    and dsa.ag = apl.arbeitsgang_nr
    GROUP BY w2.walzen_nr,
         w2.walzen_ng;
    | Id  | Operation                       | Name                           | Rows  | Bytes | Cost  |
    |   0 | SELECT STATEMENT                |                                |    21 |  1155 |  4927 |
    |   1 |  SORT GROUP BY                  |                                |    21 |  1155 |  4927 |
    |*  2 |   HASH JOIN                     |                                |    21 |  1155 |  4922 |
    |   3 |    NESTED LOOPS                 |                                |   333 | 11655 |  4682 |
    |   4 |     NESTED LOOPS                |                                | 16215 |   427K|  4682 |
    |   5 |      TABLE ACCESS BY INDEX ROWID| DURCHLAUFZEIT_SONDER_AG        |     4 |    40 |     2 |
    |*  6 |       INDEX RANGE SCAN          | DURCHLAUFZEIT_SONDER_AG_INDEX1 |     4 |       |     1 |
    |   7 |      TABLE ACCESS BY INDEX ROWID| AUFTRAG_ARBEITSPLAN            |  4054 | 68918 |  1170 |
    |*  8 |       INDEX RANGE SCAN          | AUFTRAG_ARBEITSPLAN_IND3       |  4054 |       |     7 |
    |*  9 |     INDEX RANGE SCAN            | DURCHLAUFZEIT_SONDER_AG_INDEX2 |     1 |     8 |       |
    |  10 |    *TABLE ACCESS FULL*            | WALZE                          | 75432 |  1473K|   239 |
    --------------------------------------------------------------------------------------------------When I start the same sql with providing the select from tabel "durchlaufzeit_sonder_ag" by my own the index is used:
    select /*+ index(apl(arbeitsgang_nr))*/
           /*+ index(w2 WALZE_IND1)*/
            SUM (dsa.tage) tage,
             w2.walzen_nr walzen_nr,
            w2.walzen_ng walzen_ng
          from durchlaufzeit_sonder_ag dsa,
               auftrag_arbeitsplan apl,
               walze w2
          where apl.arbeitsgang_nr in
                          ( 743, 719, 706, 979 )
    and apl.auftr_nr = w2.auftr_nr
    and apl.auftr_jj = w2.auftr_jj
    and apl.auftr_pos = w2.auftr_pos
    and apl.auftr_los = w2.auftr_los
    and dsa.abteilung = 'TM'
    and dsa.ag = apl.arbeitsgang_nr
    GROUP BY w2.walzen_nr,
    w2.walzen_ng;
    | Id  | Operation                        | Name                           | Rows  | Bytes | Cost  |
    |   0 | SELECT STATEMENT                 |                                |     2 |    94 |  1161 |
    |   1 |  SORT GROUP BY                   |                                |     2 |    94 |  1161 |
    |   2 |   TABLE ACCESS BY INDEX ROWID    | WALZE                          |     1 |    20 |     2 |
    |   3 |    NESTED LOOPS                  |                                |     2 |    94 |  1156 |
    |*  4 |     HASH JOIN                    |                                |    31 |   837 |  1094 |
    |   5 |      INLIST ITERATOR             |                                |       |       |       |
    |   6 |       TABLE ACCESS BY INDEX ROWID| DURCHLAUFZEIT_SONDER_AG        |     3 |    30 |     2 |
    |*  7 |        INDEX RANGE SCAN          | DURCHLAUFZEIT_SONDER_AG_INDEX2 |     3 |       |     1 |
    |   8 |      INLIST ITERATOR             |                                |       |       |       |
    |   9 |       TABLE ACCESS BY INDEX ROWID| AUFTRAG_ARBEITSPLAN            |  2276 | 38692 |  1091 |
    |* 10 |        INDEX RANGE SCAN          | AUFTRAG_ARBEITSPLAN_IND3       |  2276 |       |     8 |
    |* 11 |     INDEX RANGE SCAN             | WALZE_IND1                     |     1 |       |     1 |
    ---------------------------------------------------------------------------------------------------I do not understand this. Why oracle do not use the index (provided in hint) when I select the values from table durchlaufzeit_sonder_ag, but when providing the values by my own, it uses the index?

    As far as I am aware only the first hint comment within a given query block is considered.
    So these would be valid (provided hint_one is correctly specified)...
    SELECT /*+ hint_one hint_two */
           column_name
    FROM   table_name;
    SELECT /*+
           hint_one
           hint_two
           column_name
    FROM   table_name;
    SELECT /*+ hint_one
           hint_two */
           column_name
    FROM   table_name;
    SELECT --+ hint_one hint_two
           column_name
    FROM   table_name;But this would not (irrespective of whether hint_one is correctly specified)...
    SELECT /*+ hint_one */
           /*+ hint_two */
           column_name
    FROM   table_name;Also I don't believe your specification of the INDEX hint is correct, a single set of parenthesis should be used and the table alias and index name should be separated by either a space or comma.
    So these would be fine...
    SELECT /*+ INDEX (table_alias index_name) */
           column_name
    FROM   table_name;
    SELECT /*+ INDEX (table_alias, index_name) */
           column_name
    FROM   table_name;But this would not...
    SELECT /*+ INDEX (table_alias (index_name)) */
           column_name
    FROM   table_name;Also you should be aware that an INDEX hint will only be considered provided that a given join order supports it.

  • Index in not used

    Hi Guys,
    I have a table FOLDER_CUSTOMER which has two columns folder_id and customer_id.
    We have index on the customer id but the customer_id is in this format '000900000000000000000000035102' which is same for most of the customers except the last 5 digits .So the index is not getting used.
    Can any one give me some inputs for getting the index used and also some tuning thoughts.
    The sql query is below
    SELECT FC1.FOLDER_ID FROM FOLDER_CUSTOMER FC1 WHERE FC1.CUSTOMER_ID ='000900000000000000000000035102';
    Regards,
    Papi

    957590 wrote:
    Thank you guys for all these inputs.
    What I think the index is not being used because the indexed column has the values which has all most same data only difference in the last few numbers.So is there any way to create optimal index like function based index or reverse key index to help to perform better.
    >Thank you guys for all these inputs.
    What I think the index is not being used because the indexed column has the values which has all most same data only difference in the last few numbers.So is there any way to create optimal index like function based index or reverse key index to help to perform better.
    No, I don't think it is to do with that. If they are unique values it doesn't matter if they only differ in the last few digits.
    However, I suspect you have multiple rows with the same value in that table.
    Remember indexed access can be slower than a full table scan in certain circumstances.
    We need more information, please read: {message:id=9360003} and follow the advice there.

  • Why index is not used if oracle have to do implicit conversion?

    my db version: 10gR2
    I created bitmap index on each of the column used in below sql.
    the datatype of all three columns are VARCHAR2,
    while i am using NUMBER in the query, which means oracle needs to do the implicit conversion before running the sql.
    the problem is that, when I use NUMBER as below, execution plan will not use bitmap indexes at all.
    but when I use STRING instead, it will make use of those bitmap indexes.
    select  FI_YTD,1,2,FI_KPI_ID
      from DM_F_FI_ALL_KPI
      where
        FI_KPI_ID=4140
        and FI_PERIOD=201012
        and FI_ORG_ID=10000000;So, I wonder why? how the implicit conversion affects the access path?
    Edited by: PhoenixBai on Jan 30, 2011 10:52 AM
    Edited by: PhoenixBai on Jan 31, 2011 9:21 AM --added database version as 10gR2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    sybrand_b wrote:
    Implicit conversion in Oracle is always done like this
    empno='10'
    is rewritten as
    to_char(empno)='10'
    Now you have <function>(<indexed columnn>) = <hardcoded literal>
    Oracle never puts a conversion function at the right hand side of the expresssion. NEVER.
    SQL> create table emp as select * from scott.emp;
    Table created.
    SQL> alter table emp add constraint emp_pk primary key (empno);
    Table altered.
    SQL> @desc emp
    Name                                      Null?    Type
    EMPNO                                     NOT NULL NUMBER(4)
    ENAME                                              VARCHAR2(10)
    JOB                                                VARCHAR2(9)
    MGR                                                NUMBER(4)
    HIREDATE                                           DATE
    SAL                                                NUMBER(7,2)
    COMM                                               NUMBER(7,2)
    DEPTNO                                             NUMBER(2)
    SQL> select * from emp where empno = '10'
      2
    SQL> @xplan
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    Compatibility is set to 11.2.0.0.0
    Plan hash value: 4024650034
    | Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |        |     1 |    87 |     1   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    87 |     1   (0)| 00:00:01 |
    |*  2 |   INDEX UNIQUE SCAN         | EMP_PK |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("EMPNO"=10)Edited by: William Robertson on Jan 30, 2011 12:56 PM - added DESCRIBE

  • Performance issue in SQL while using max

    Hi
    I have log table which desired changed date. if any transaction entered for the changed date and less, then the name and location should be shown based on change log table. if change log entry has two values for a same date for a customer then need to show the max value for the row.
    Log table
    ID   CUSTOMER_ID                NAME        LOCATION      CHANGED_DATE
    1          1                      sar          boston          11-1-13
    2          2                      var          chn             12-1-13
    3          1                      gar          boston          13-1-13
    4          1                      nar          boston          13-1-13
    Transaction table
    ID            CUSTOMER_ID               DATE         QTY  
    1                 1                    11-1-13       10
    2                 2                    12-1-13        9
    3                 1                    10-1-13        8
    4                 1                    13-1-13        7
    Required Result
    ID            CUSTOMER_ID                 NAME               LOCATION            DATE         QTY  
    1                 1                       sar                  boston            11-1-13       10
    2                 2                       var                  chn               12-1-13        9
    3                 1                       sar                  boston            10-1-13        8
    4                 1                       nar                  boston            13-1-13        7I got the above result using the max when multiple log entry for same date. but if use max value i got performance issue when log entry table has more entries.
    can you help me in this?
    Edited by: Tsk on Apr 23, 2013 1:12 AM

    How do I ask a question on the forums?
    SQL and PL/SQL FAQ

  • Measue aggregation not used when OBIEE hits MV

    Hi,
    We are facing 1 issue in MV implementation in OBIEE i.e. aggregation is not used for measure when OBIEE hits the MV and it's using the aggregation when OBIEEhits the base table.Ex. A is a column with aggregation sum when we pull measure A for ttime dimension when it's hitting MV it's not using sum in obiee query and when it's hitting base table it's uisng sum.Can anyone tell me how can we overcome this issue.
    Thanks,
    Amrit

    Hi Rajagopal,
    I am not sure if that is exactly accurate as I have other tables where the LTS includes a second or even third table but both tables are not included in the query.
    Example 1 - Table 1 joined to Table 2. Table 2 is setup as a LTS on Table 1. When a report is created off of Table 2, Table 1 is not included in the query.
    Example 2 - Table 1 joined to Table 2. Table 1 is setup as a LTS on Table 2. When a report is created off of Table 2, Table 1 is not included in the query.
    I have also verified that there is no other LTS on the Customer table but the issue still exists.
    Any other thoughts you can provide would be appreciated.
    Thanks

  • Index isn't used when specifying IS NULL

    Hello,
    I'm using Oracle 10.2.0.4. When I run this statement, the explain plan shows that a composite index is used which is expected.
    select * from isis.cour_off where orga_# = 4
    However, when I run the following statement, the explain plan shows FULL TABLE SCAN:
    select * from isis.cour_off where orga_# IS NULL
    Is this to be expected? If so, then why?

    Centinul wrote:
    If I had to wager a guess it's probably because the OP is selecting all the columns anyways so it's probably more efficient to use multi-block reads to retrieve the entire rows from the table. However, that's hard to say without data.Not really. It is not data what drives optimizer to use index or not in the first stage. In case of single column index main question is: is column NULLable? But, as you noted, OP has composite index . Therefore, question "is column NULLable" transforms into are all index columns NULLable? If they are - index can't be used no matter what, since it is possible table has rows where all index columns are NULL and therefore there will be no index entry for such row. If at least one index column is NOT NULL, index can be (doesn't mean will be) used:
    SQL> create table tbl
      2  as
      3  select level id,case mod(level,1000) when 0 then to_number(null) else level end val from dual connect by level <= 100000;
    Table created.
    SQL> create index tbl_idx on tbl(val,id);
    Index created.
    SQL> exec dbms_stats.gather_table_stats('SCOTT','TBL');
    PL/SQL procedure successfully completed.
    SQL> explain plan for select * from tbl where val is null;
    Explained.
    SQL> @?\rdbms\admin\utlxpls
    PLAN_TABLE_OUTPUT
    Plan hash value: 2144214008
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |   100 |   900 |    53   (8)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| TBL  |   100 |   900 |    53   (8)| 00:00:01 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       1 - filter("VAL" IS NULL)
    13 rows selected.
    SQL> alter table tbl modify id not null;
    Table altered.
    SQL> explain plan for select * from tbl where val is null;
    Explained.
    SQL> @?\rdbms\admin\utlxpls
    PLAN_TABLE_OUTPUT
    Plan hash value: 2817369304
    | Id  | Operation        | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT |         |   100 |   900 |     2   (0)| 00:00:01 |
    |*  1 |  INDEX RANGE SCAN| TBL_IDX |   100 |   900 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       1 - access("VAL" IS NULL)
    13 rows selected.
    SQL> As you can see, even though column ID did not have any NULL values index wasn't used since potentially ID can be null. As soon as column ID was set to NOT NULL optimizer started using index.
    SY.

Maybe you are looking for