Query on virtual column that is defined in XMLIndex does not use the index

Hello,
I am facing an issue in executing queries on a virtual column that is defined in an XMLIndex: it appears as if the index is not used.
Database details:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for 64-bit Windows: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
For this use case the XML documents adhere to the following XSD and are stored in an XMLType column in a table:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns="http://a_name_space/v1"
    targetNamespace="http://a_name_space/v1"
    elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0">
    <xsd:element name="fields">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="field" maxOccurs="unbounded">
                    <xsd:complexType>
                        <xsd:choice>
                            <xsd:element name="value" minOccurs="1" maxOccurs="1">
                                <xsd:complexType>
                                    <xsd:simpleContent>
                                        <xsd:extension base="notEmptyString4000Type"/>
                                    </xsd:simpleContent>
                                </xsd:complexType>
                            </xsd:element>
                            <xsd:element name="values" minOccurs="1" maxOccurs="1">
                                <xsd:complexType>
                                    <xsd:sequence>
                                        <xsd:element name="value" minOccurs="1" maxOccurs="1">
                                            <xsd:complexType>
                                                <xsd:simpleContent>
                                                    <xsd:extension base="notEmptyString4000Type">
                                                        <xsd:attribute name="startDate" type="xsd:date" use="required"/>
                                                        <xsd:attribute name="endDate" type="xsd:date" />
                                                    </xsd:extension>
                                                </xsd:simpleContent>
                                            </xsd:complexType>
                                        </xsd:element>
                                    </xsd:sequence>
                                </xsd:complexType>
                            </xsd:element>
                        </xsd:choice>
                        <xsd:attribute name="name" type="string30Type" use="required"/>
                        <xsd:attribute name="type" type="dataType" use="required"/>
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:simpleType name="dataType">
        <xsd:annotation>
            <xsd:documentation>Char, Date, Number</xsd:documentation>
        </xsd:annotation>
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="C"/>
            <xsd:enumeration value="D"/>
            <xsd:enumeration value="N"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="string30Type">
        <xsd:restriction base="xsd:string">
            <xsd:maxLength value="30"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="notEmptyString4000Type">
        <xsd:restriction base="xsd:string">
            <xsd:maxLength value="4000"/>
            <xsd:pattern value=".+"/>
        </xsd:restriction>
    </xsd:simpleType>
</xsd:schema>A field can have a single value as well as multiple values.
The XMLIndex is defined as follows:
CREATE INDEX test_xmltype_idx ON test_xmltype (additional_fields) INDEXTYPE IS XDB.XMLIndex
PARAMETERS
XMLTable dt_fld_tab (TABLESPACE "TAB_SPACE" COMPRESS FOR OLTP) ''fields/field''
COLUMNS
name varchar2(30 char) PATH ''@name''
,dataType varchar2(1 char) PATH ''@type''
,val varchar2(4000 char) PATH ''value/text()''
,vals XMLType PATH ''values/value'' VIRTUAL
XMLTable dt_fld_multi_value_tab (TABLESPACE "TAB_SPACE" COMPRESS FOR OLTP) ''value'' passing vals
COLUMNS
val varchar2(4000) PATH ''text()''
,startDate varchar2(30 char) PATH ''@startDate''
,endDate varchar2(30 char) PATH ''@endDate''
');The following b-tree indexes are defined:
create index dt_field_name_idx on dt_fld_tab (name);
create index dt_field_value_idx on dt_fld_tab (val);
create index dt_field_values_idx on dt_fld_multi_value_tab (val);And stats are properly computed before the queries are executed:
call dbms_stats.gather_table_stats(user, 'test_xmltype', estimate_percent => null);Queries for single values are cost efficient and fast. With 600K rows in the table these return with 0.002 seconds.
Queries for multi-valued fields / elements are not though, these result in a full table scan.
Sample XML snippet:
<fields>
  <field name="multiVal" type="C">
    <values>
      <value startDate="2013-01-01" endDate="2013-01-01">100</value>
      <value startDate="2014-01-01">120</value>
    </values>
  </field>
</fields>Examples of costly and slow queries:
select id from test_xmltype
where xmlexists('/fields/field/@name="multiVal"' passing additional_fields)
and xmlexists('/fields/field/values/value[@startDate="2013-01-01"]' passing additional_fields)
and xmlexists('/fields/field/values/value[text()="100"]' passing additional_fields)
select id from test_xmltype
where xmlexists('/fields/field/@name="multiVal"' passing additional_fields)
and xmlexists('/fields/field/values/value[@startDate="2013-01-01" and .="100"]' passing additional_fields);Whereas the following query on the multi valued field is fast:
select id from test_xmltype
where xmlexists('/fields/field/@name="multiVal"' passing additional_fields)
and xmlexists('/fields/field/values/value[@startDate="2013-01-01"]' passing additional_fields);For the XPath /fields/field/values/value[@startDate="2013-01-01"] the index is used.
Suspected cause: XPath issue for the value of a multi valued field, e.g. /fields/field/values/value[text()="aValue"].
Any hints are appreciated: what am I overlooking here?
Thanks in advance,
-Sjoerd
Edited by: user615230 on May 27, 2013 7:46 AM

Hello,
This is using binary XML. The table creation script is:
create table test_xmltype
(id number(14,0) not null primary key
,member_code varchar2(30 char) not null
,period_code varchar2(30 char) not null
,amount number(12,2) not null
,additional_fields xmltype
);The schema is not registered in the database. Is that required? It is primarily used to generate Java classes that will be used in order to construct the XML documents.
And you are right: for our initial investigation the sample XML documents are generated with a PLSQL routine and do not contain namespaces. But for the single valued fields there are also no namespaces and the queries on these are executed with very satisfactory plans.
Thanks for the swift reply.
-Sjoerd

Similar Messages

  • Why is this query not using the index?

    check out this query:-
    SELECT CUST_PO_NUMBER, HEADER_ID, ORDER_TYPE, PO_DATE
    FROM TABLE1
    WHERE STATUS = 'N'
    and here's the explain plan:-
    1     
    2     -------------------------------------------------------------------------------------
    3     | Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
    4     -------------------------------------------------------------------------------------
    5     | 0 | SELECT STATEMENT | | 2735K| 140M| 81036 (2)|
    6     |* 1 | TABLE ACCESS FULL| TABLE1 | 2735K| 140M| 81036 (2)|
    7     -------------------------------------------------------------------------------------
    8     
    9     Predicate Information (identified by operation id):
    10     ---------------------------------------------------
    11     
    12     1 - filter("STATUS"='N')
    There is already an index on this column, as is shown below:-
         INDEX_NAME INDEX_TYPE     UNIQUENESS     TABLE_NAME     COLUMN_NAME     COLUMN_POSITION
    1     TABLE1_IDX2 NORMAL     NONUNIQUE     TABLE1      STATUS     1
    2     TABLE1_IDX NORMAL     NONUNIQUE     TABLE1     HEADER_ID     1
    So why is this query not using the index on the 'STATUS' Column?
    I've already tried using optimizer hints and regathering the stats on the table, but the execution plan still remains the same, i.e. it still uses a FTS.
    I have tried this command also:-
    exec dbms_stats.gather_table_stats('GECS','GEPS_CS_SALES_ORDER_HEADER',method_opt=>'for all indexed columns size auto',cascade=>true,degree=>4);
    inspite of this, the query is still using a full table scan.
    The table has around 55 Lakh records, across 60 columns. And because of the FTS, the query is taking a long time to execute. How do i make it use the index?
    Please help.
    Edited by: user10047779 on Mar 16, 2010 6:55 AM

    If the cardinality is really as skewed as that, you may want to look at putting a histogram on the column (sounds like it would be in order, and that you don't have one).
    create table skewed_a_lot
    as
       select
          case when mod(level, 1000) = 0 then 'N' else 'Y' end as Flag,
          level as col1
       from dual connect by level <= 1000000;
    create index skewed_a_lot_i01 on skewed_a_lot (flag);
    exec dbms_stats.gather_table_stats(user, 'SKEWED_A_LOT', cascade => true, method_opt => 'for all indexed columns size auto');Is an example.

  • Query not using the index

    Query
    SELECT case.case_objid FROM [email protected] case, table_x_cwp_tickect_details_vw t WHERE CASE.case_condition_cd IN ('OPEN', 'OPEN-DISPATCH', 'OPEN-REJECT', 'OPEN-RETURNED') AND case.case_type_cd in ('CUSTOMER FAULT', 'CHRONIC','SCHEDULED ACTIVITY','PROBLEM') AND ROWNUM <= 500 AND case.case_objid = t.ticket_objid AND ( ( case.account_id = '672286' ) ) ORDER BY case.case_id DESC
    From PROD
    Plan
    SELECT STATEMENT HINT: FIRST_ROWS Cost: 2,629 Bytes: 221,500 Cardinality: 500
         37 SORT ORDER BY Cost: 2,629 Bytes: 221,500 Cardinality: 500
              36 COUNT STOPKEY
                   35 NESTED LOOPS OUTER Cost: 2,628 Bytes: 279,533 Cardinality: 631
                        33 HASH JOIN OUTER Cost: 2,627 Bytes: 275,116 Cardinality: 631
                             31 NESTED LOOPS OUTER Cost: 2,249 Bytes: 266,282 Cardinality: 631
                                  28 NESTED LOOPS Cost: 1,766 Bytes: 257,448 Cardinality: 631
                                       26 NESTED LOOPS Cost: 1,765 Bytes: 253,031 Cardinality: 631
                                            24 NESTED LOOPS Cost: 1,764 Bytes: 248,614 Cardinality: 631
                                                 22 NESTED LOOPS Cost: 1,763 Bytes: 244,197 Cardinality: 631
                                                      19 NESTED LOOPS Cost: 1,258 Bytes: 235,363 Cardinality: 631
                                                           17 NESTED LOOPS Cost: 1,257 Bytes: 230,946 Cardinality: 631
                                                                14 NESTED LOOPS OUTER Cost: 752 Bytes: 217,695 Cardinality: 631
                                                                     12 HASH JOIN Cost: 751 Bytes: 213,278 Cardinality: 631
                                                                          1 INDEX FAST FULL SCAN INDEX (UNIQUE) SA.GBST_ELM_OBJINDEX Cost: 2 Bytes: 10,052 Cardinality: 1,436
                                                                          11 HASH JOIN Cost: 748 Bytes: 208,861 Cardinality: 631
                                                                               2 INDEX FAST FULL SCAN INDEX (UNIQUE) SA.GBST_ELM_OBJINDEX Cost: 2 Bytes: 10,052 Cardinality: 1,436
                                                                               10 HASH JOIN Cost: 746 Bytes: 204,444 Cardinality: 631
                                                                                    3 INDEX FAST FULL SCAN INDEX (UNIQUE) SA.GBST_ELM_OBJINDEX Cost: 2 Bytes: 10,052 Cardinality: 1,436
                                                                                    9 HASH JOIN Cost: 743 Bytes: 200,027 Cardinality: 631
                                                                                         4 INDEX FAST FULL SCAN INDEX (UNIQUE) SA.GBST_ELM_OBJINDEX Cost: 2 Bytes: 10,052 Cardinality: 1,436
                                                                                         8 NESTED LOOPS Cost: 741 Bytes: 195,610 Cardinality: 631
                                                                                              5 REMOTE REMOTE CASE Cost: 235 Bytes: 156,488 Cardinality: 631
                                                                                              7 TABLE ACCESS BY INDEX ROWID TABLE SA.TABLE_CASE Cost: 1 Bytes: 62 Cardinality: 1
                                                                                                   6 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.TC_C_CASE_OBJINDEX Cost: 1 Cardinality: 1
                                                                     13 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.UN_PTT2CASE Cost: 1 Bytes: 7 Cardinality: 1
                                                                16 TABLE ACCESS BY INDEX ROWID TABLE SA.TABLE_SITE Cost: 1 Bytes: 21 Cardinality: 1
                                                                     15 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.SITE_OBJINDEX Cost: 1 Cardinality: 1
                                                           18 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.BUS_ORG_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
                                                      21 TABLE ACCESS BY INDEX ROWID TABLE SA.TABLE_ADDRESS Cost: 1 Bytes: 14 Cardinality: 1
                                                           20 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.ADDRESS_OBJINDEX Cost: 1 Cardinality: 1
                                                 23 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.COUNTRY_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
                                            25 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.CONTACT_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
                                       27 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.CONDITION_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
                                  30 TABLE ACCESS BY GLOBAL INDEX ROWID TABLE SA.TABLE_SITE_PART Cost: 1 Bytes: 14 Cardinality: 1 Partition #: 34
                                       29 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.SITE_PART_OBJINDEX Cost: 1 Cardinality: 1
                             bold 32 TABLE ACCESS FULL TABLE SA.TABLE_MOD_LEVEL Cost: 376 Bytes: 1,442,084 Cardinality: 103,006 bold
                        34 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.PART_NUM_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
    From DEV platform
    Plan
    SELECT STATEMENT HINT: FIRST_ROWS Cost: 591 Bytes: 61,134 Cardinality: 138
         37 SORT ORDER BY Cost: 591 Bytes: 61,134 Cardinality: 138
              36 COUNT STOPKEY
                   35 HASH JOIN Cost: 590 Bytes: 61,134 Cardinality: 138
                        1 INDEX FAST FULL SCAN INDEX (UNIQUE) SA.GBST_ELM_OBJINDEX Cost: 2 Bytes: 10,045 Cardinality: 1,435
                        34 HASH JOIN Cost: 588 Bytes: 60,168 Cardinality: 138
                             2 INDEX FAST FULL SCAN INDEX (UNIQUE) SA.GBST_ELM_OBJINDEX Cost: 2 Bytes: 10,045 Cardinality: 1,435
                             33 HASH JOIN Cost: 585 Bytes: 59,202 Cardinality: 138
                                  3 INDEX FAST FULL SCAN INDEX (UNIQUE) SA.GBST_ELM_OBJINDEX Cost: 2 Bytes: 10,045 Cardinality: 1,435
                                  32 HASH JOIN Cost: 583 Bytes: 58,236 Cardinality: 138
                                       4 INDEX FAST FULL SCAN INDEX (UNIQUE) SA.GBST_ELM_OBJINDEX Cost: 2 Bytes: 10,045 Cardinality: 1,435
                                       31 NESTED LOOPS OUTER Cost: 580 Bytes: 57,270 Cardinality: 138
                                            29 NESTED LOOPS OUTER Cost: 579 Bytes: 56,304 Cardinality: 138
                                                 27 NESTED LOOPS OUTER Cost: 469 Bytes: 54,372 Cardinality: 138
                                                      24 NESTED LOOPS Cost: 363 Bytes: 52,440 Cardinality: 138
                                                           22 NESTED LOOPS Cost: 362 Bytes: 51,474 Cardinality: 138
                                                                20 NESTED LOOPS Cost: 361 Bytes: 50,508 Cardinality: 138
                                                                     18 NESTED LOOPS Cost: 360 Bytes: 49,542 Cardinality: 138
                                                                          15 NESTED LOOPS Cost: 249 Bytes: 47,610 Cardinality: 138
                                                                               13 NESTED LOOPS Cost: 248 Bytes: 46,644 Cardinality: 138
                                                                                    10 NESTED LOOPS OUTER Cost: 138 Bytes: 43,746 Cardinality: 138
                                                                                         8 NESTED LOOPS Cost: 137 Bytes: 42,780 Cardinality: 138
                                                                                              5 REMOTE REMOTE CASE Cost: 26 Bytes: 34,224 Cardinality: 138
                                                                                              7 TABLE ACCESS BY INDEX ROWID TABLE SA.TABLE_CASE Cost: 1 Bytes: 62 Cardinality: 1
                                                                                                   6 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.TC_C_CASE_OBJINDEX Cost: 1 Cardinality: 1
                                                                                         9 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.UN_PTT2CASE Cost: 1 Bytes: 7 Cardinality: 1
                                                                                    12 TABLE ACCESS BY INDEX ROWID TABLE SA.TABLE_SITE Cost: 1 Bytes: 21 Cardinality: 1
                                                                                         11 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.SITE_OBJINDEX Cost: 1 Cardinality: 1
                                                                               14 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.BUS_ORG_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
                                                                          17 TABLE ACCESS BY INDEX ROWID TABLE SA.TABLE_ADDRESS Cost: 1 Bytes: 14 Cardinality: 1
                                                                               16 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.ADDRESS_OBJINDEX Cost: 1 Cardinality: 1
                                                                     19 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.COUNTRY_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
                                                                21 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.CONTACT_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
                                                           23 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.CONDITION_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
                                                      26 TABLE ACCESS BY GLOBAL INDEX ROWID TABLE SA.TABLE_SITE_PART Cost: 1 Bytes: 14 Cardinality: 1 Partition #: 34
                                                           25 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.SITE_PART_OBJINDEX Cost: 1 Cardinality: 1
                                       bold           28 INDEX RANGE SCAN INDEX SA.IND_PART_INFO2PART_NUM Cost: 1 Bytes: 14 Cardinality: 1 bold
                                            30 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.PART_NUM_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
    Conclusion:
    IND_PART_INFO2PART_NUM is not in use in Production environment
    PROD
    1. SQL> select index_name,NUM_ROWS,CLUSTERING_FACTOR from dba_indexes where index_name='IND_PART_INFO2PART_NUM';
    INDEX_NAME NUM_ROWS CLUSTERING_FACTOR
    IND_PART_INFO2PART_NUM 103023 46488
    DEV environment
    SQL> select index_name,NUM_ROWS,CLUSTERING_FACTOR,table_name from dba_indexes where index_name='IND_PART_INFO2PART_NUM';
    INDEX_NAME NUM_ROWS CLUSTERING_FACTOR TABLE_NAME
    IND_PART_INFO2PART_NUM 101982 45722 TABLE_MOD_LEVEL
    1. Index is rebuild
    2. stats are up to date
    3. Redef on table is done.
    Still no change in the plan .

    Osama-mustafa wrote:
    Aman.... wrote:
    Osama-mustafa wrote:
    alter index <index-name> rebuild ;Why?
    Aman....I faced this issue with query and indexes was need rebuildWhat issue Osama-that query wasn't using index and after rebuild it did start using it? Not just that this reply is wrong , this is OP has mentioned that he has done already. Please note that index rebuild is not the answer when the query is not using the index. There can be many reasons behind it. Have a look at Richard Foote's blog where he explains all of this in a very detailed way and in many posts.
    Aman....

  • My table of contents does not use the entry style I select for words in the paragraph that have character styles applied to them in the chapter, so some of the letters are showing up as green, which is fine in the chapter but not in the TOC.

    My table of contents does not use the entry style I select for words in the paragraph that have character styles applied to them in the chapter, so some of the letters, specifically parameters, are showing up green, which is fine in the chapter but not in the TOC. I can manually fix this in the TOC by changing the character style to none after the toc  has been generated, but I don't want to do this.

    What application are you running? Please ask this in the forum of the product you're using.

  • [svn:fx-trunk] 16929: Add a [Mixin] class that will register the required class aliases in the event the mxml compiler generation   [RemoteClass(alias="")] code is not called because an application does not use the Flex UI framework .

    Revision: 16929
    Revision: 16929
    Author:   [email protected]
    Date:     2010-07-15 07:38:44 -0700 (Thu, 15 Jul 2010)
    Log Message:
    Add a class that will register the required class aliases in the event the mxml compiler generation  [RemoteClass(alias="")] code is not called because an application does not use the Flex UI framework.
    Add a reference to this class in the RPCClasses file so it always gets loaded.
    QE notes: Need a remoting and messaging regression test that doesn't use Flex UI.
    Bugs: Watson bug 2638788
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/rpc/src/RPCClasses.as
    Added Paths:
        flex/sdk/trunk/frameworks/projects/rpc/src/mx/utils/RpcClassAliasInitializer.as

    Great exercise to document the problem like this.  It got me thinking about how an app with modules would be different from an app that does not use modules.  Solution: I moved the dummy reference of PersonPhotoView out to the main application file (as opposed to being inside the module) and it worked.  I've probably been lucky not to have experienced this problem earlier, because for most other entities I have an instance attached to my model which is linked / compiled with the main application.

  • TS1646 When I try to buy music, I get message saying that my credit card information does not match the bank records. My information, formatting are exactly the same as the bank. Help!

    When I try to buy music, I get message saying that my credit card information does not match the bank records. My information, formatting are exactly the same as the bank. Help!

    Look on one of your bank statements and be sure to enter the billing address exactly as it shows on the statement. Some folks forget where they actually get the statement. They put their home address in iTunes/Mac App Store and they actually get the statement at their place of employment or vice versa.

  • After i bought mac os x lion from web then download , after that to install but when they ask me to choose disk to install i can not choose, it say this disk does not use the GUID partiton table scheme. use disk utility to change the partition scheme. but

    after i bought mac os x lion from web then download , after that to install but when they ask me to choose disk to install i can not choose, it say this disk does not use the GUID partiton table scheme. use disk utility to change the partition scheme. but

    after i bought mac os x lion from web then download , after that to install but when they ask me to choose disk to install i can not choose, it say this disk does not use the GUID partiton table scheme. use disk utility to change the partition scheme. but

  • Query is not using the INDEX

    I have issue with a query as follows. It is not using index when i keep a function on the left hand side of comparison in where condition.
    But when I remove the function it is using index.
    With BLC AS
    Name                                      Null?    Type
    ID                                        NOT NULL NUMBER
    MASTER_VALUE               NOT NULL NUMBER(8)
    DESC_TEXT_ID                                    NUMBER
    GVM                                                     VARCHAR2(50)
    MASTER_LOOKUP_ID    NOT NULL  NUMBER
    WORK_SECTION_ID                          NUMBER
    AUDIT_TRAIL_NO                              NUMBER
    SQL> SELECT COUNT(*) FROM BLC;
      COUNT(*)
          7769
    SQL> SELECT COUNT(DISTINCT(GVM)) "distinct" FROM BLC;
      distinct
          1350
    SQL> SELECT COUNT(*) "nulls" FROM BLC WHERE GVM IS NULL;
         nulls
          6419
    SQL> SELECT COLUMN_NAME,INDEX_NAME FROM DBA_IND_COLUMNS WHERE TABLE_NAME='BLC';
    COLUMN_NAME                              INDEX_NAME
    MASTER_LOOKUP_ID      LKPCDE_MSTLKP_FK_I
    WORK_SECTION_ID        LKPCDE_WRKSEC_FK_I
    GVM                                   LKPCDE_UK
    MASTER_VALUE              LKPCDE_MASTERID_VALUE_UK
    MASTER_LOOKUP_ID     LKPCDE_MASTERID_VALUE_UK
    ID                                       LKPCDE_PK
    SQL> EXPLAIN PLAN FOR SELECT ID FROM BLC WHERE UPPER ( GVM) = 'MAIN_ORG';
    Explained.
    SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3196655606
    | Id  | Operation         | Name             | Rows  | Bytes | Cost (%CPU)| Time|
    PLAN_TABLE_OUTPUT
    |   0 | SELECT STATEMENT  |                  |    78 |   624 |    18   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| BLC |    78 |   624 |    18   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       1 - filter(UPPER("GVM")='MAIN_ORG')
    13 rows selected.
    SQL> EXPLAIN PLAN FOR SELECT ID FROM BLC WHERE GVM
      = 'MAIN_ORG';
    Explained.
    SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
    PLAN_TABLE_OUTPUT
    Plan hash value: 1620245961
    | Id  | Operation                   | Name             | Rows  | Bytes | Cost (%
    CPU)| Time     |
    PLAN_TABLE_OUTPUT
    |   0 | SELECT STATEMENT            |                  |     1 |     8 |     2
    (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| BLC |     1 |     8 |     2
    (0)| 00:00:01 |
    |*  2 |   INDEX UNIQUE SCAN         | LKPCDE_UK        |     1 |       |     1
    (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       2 - access("GVM"='MAIN_ORG')
    14 rows selected.
    SQL> EXPLAIN PLAN FOR SELECT /* INDEX(LKPCDE_UK) */ ID FROM BLC WHE
    RE UPPER ( GVM ) = 'MAIN_ORG';
    Explained.
    SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3196655606
    | Id  | Operation         | Name             | Rows  | Bytes | Cost (%CPU)| Time
         |
    PLAN_TABLE_OUTPUT
    |   0 | SELECT STATEMENT  |                  |    78 |   624 |    18   (0)| 00:0
    0:01 |
    |*  1 |  TABLE ACCESS FULL| BLC |    78 |   624 |    18   (0)| 00:0
    0:01 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       1 - filter(UPPER("GVM")='MAIN_ORG')
    13 rows selected.
    Please let me know how i can force to use an index as it is causing CPU usage.
    I can not change the query in application as it is used at many places.
    Thanks

    Hi,
    Version is
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    PL/SQL Release 10.2.0.5.0 - Production
    CORE    10.2.0.5.0      Production
    TNS for 64-bit Windows: Version 10.2.0.5.0 - Production
    NLSRTL Version 10.2.0.5.0 - Production
    Sorry, in my last post i forgot to mention that i already created a function based index but still it is not using because, there is a UNIQUE constraint on that column.
    Thanks

  • Query startdate and end date not using the index

    Hi,
    in my query all the where  i am using  the code as below
    AND START_DATE                   <= SYSDATE
    AND SYSDATE  <= END_DATE
    because of this my query seems to slow and timeconsuming. is there any other alternate way?
    Pls help
    S

    KARTHIK,
    this is my query
    SELECT /*+ PARALLEL(CUSTOMER, 4)PARALLEL(CUSTOMER_MANAGER, 4),PARALLEL(CUSTOMER_DIVISION, 4) */
    CUSTOMER.CUSTOMER_EID 
    FROM  CUSTOMER_   CUSTOMER,
    CUSTOMER_MANAGER_ CUSTOMER_MANAGER,
    CUSTOMER_DIVISION_   CUSTOMER_DIVISION
    WHERE   CUSTOMER_MANAGER.CUSTOMER_EID   = CUSTOMER.CUSTOMER_EID
    AND CUSTOMER.CUSTOMER_EID               = CUSTOMER_DIVISION.CUSTOMER_EID
    AND  CUSTOMER_MANAGER.CUSTOMER_EID   = CUSTOMER_DIVISION.CUSTOMER_EID
    AND ( TRUNC(SYSDATE) BETWEEN CUSTOMER_MANAGER.DIVISION_START_DATE   AND CUSTOMER_MANAGER.DIVISION_END_DATE
    AND  TRUNC(SYSDATE) BETWEEN CUSTOMER_DIVISION.DIVISION_START_DATE   AND CUSTOMER_DIVISION.DIVISION_END_DATE )
    AND CUSTOMER_DIVISION.STATUS             ='AC';
    plan output is as below
    Plan hash value: 2500183415
    | Id  | Operation                     | Name              | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     | Pstart| Pstop |    TQ  |IN-OUT| PQ Distrib |
    |   0 | SELECT STATEMENT              |                   |     1 |    53 |       |   360K  (1)| 01:12:04 |       |       |        |      |            |
    |   1 |  PX COORDINATOR               |                   |       |       |       |            |          |       |       |        |      |            |
    |   2 |   PX SEND QC (RANDOM)         | :TQ10001          |     1 |    53 |       |   360K  (1)| 01:12:04 |       |       |  Q1,01 | P->S | QC (RAND)  |
    |   3 |    NESTED LOOPS               |                   |     1 |    53 |       |   360K  (1)| 01:12:04 |       |       |  Q1,01 | PCWP |            |
    |*  4 |     HASH JOIN                 |                   |    16M|   738M|   111M|   360K  (1)| 01:12:03 |       |       |  Q1,01 | PCWP |            |
    |   5 |      BUFFER SORT              |                   |       |       |       |            |          |       |       |  Q1,01 | PCWC |            |
    |   6 |       PX RECEIVE              |                   |    12M|   302M|       |   305K  (1)| 01:01:10 |       |       |  Q1,01 | PCWP |            |
    |   7 |        PX SEND PARTITION (KEY)| :TQ10000          |    12M|   302M|       |   305K  (1)| 01:01:10 |       |       |        | S->P | PART (KEY) |
    |   8 |         PARTITION HASH ALL    |                   |    12M|   302M|       |   305K  (1)| 01:01:10 |     1 |     4 |        |      |            |
    |*  9 |          TABLE ACCESS FULL    | CUSTOMER_DIVISION_ |    12M|   302M|       |   305K  (1)| 01:01:10 |     1 |     4 |        |      |            |
    |  10 |      PX PARTITION HASH ALL    |                   |    15M|   323M|       | 42663   (1)| 00:08:32 |     1 |     4 |  Q1,01 | PCWC |            |
    |* 11 |       TABLE ACCESS FULL       | CUSTOMER_MANAGER_ |    15M|   323M|       | 42663   (1)| 00:08:32 |     1 |     4 |  Q1,01 | PCWP |            |
    |* 12 |     INDEX UNIQUE SCAN         | CUSTOMER__PK      |     1 |     6 |       |     1   (0)| 00:00:01 |       |       |  Q1,01 | PCWP |            |
    Query Block Name / Object Alias (identified by operation id):
       1 - SEL$1
       9 - SEL$1 / CUSTOMER_DIVISION@SEL$1
      11 - SEL$1 / CUSTOMER_MANAGER@SEL$1
      12 - SEL$1 / CUSTOMER@SEL$1
    Predicate Information (identified by operation id):
       4 - access("CUSTOMER_MANAGER"."CUSTOMER_EID"="CUSTOMER_DIVISION"."CUSTOMER_EID")
       9 - filter("CUSTOMER_DIVISION"."STATUS"='AC' AND "CUSTOMER_DIVISION"."DIVISION_END_DATE">=TRUNC(SYSDATE@!) AND
                  "CUSTOMER_DIVISION"."DIVISION_START_DATE"<=TRUNC(SYSDATE@!))
      11 - filter("CUSTOMER_MANAGER"."DIVISION_END_DATE">=TRUNC(SYSDATE@!) AND "CUSTOMER_MANAGER"."DIVISION_START_DATE"<=TRUNC(SYSDATE@!))
      12 - access("CUSTOMER"."CUSTOMER_EID"="CUSTOMER_DIVISION"."CUSTOMER_EID")
           filter("CUSTOMER_MANAGER"."CUSTOMER_EID"="CUSTOMER"."CUSTOMER_EID")
    Column Projection Information (identified by operation id):
       1 - "CUSTOMER"."CUSTOMER_EID"[NUMBER,22]
       2 - (#keys=0) "CUSTOMER"."CUSTOMER_EID"[NUMBER,22]
       3 - (#keys=0) "CUSTOMER"."CUSTOMER_EID"[NUMBER,22]
       4 - (#keys=1) "CUSTOMER_DIVISION"."CUSTOMER_EID"[NUMBER,22], "CUSTOMER_MANAGER"."CUSTOMER_EID"[NUMBER,22]
       5 - (#keys=0) "CUSTOMER_DIVISION"."CUSTOMER_EID"[NUMBER,22]
       6 - "CUSTOMER_DIVISION"."CUSTOMER_EID"[NUMBER,22]
       7 - (#keys=1) "CUSTOMER_DIVISION"."CUSTOMER_EID"[NUMBER,22]
       8 - "CUSTOMER_DIVISION"."CUSTOMER_EID"[NUMBER,22]
       9 - "CUSTOMER_DIVISION"."CUSTOMER_EID"[NUMBER,22]
      10 - "CUSTOMER_MANAGER"."CUSTOMER_EID"[NUMBER,22]
      11 - "CUSTOMER_MANAGER"."CUSTOMER_EID"[NUMBER,22]
      12 - "CUSTOMER"."CUSTOMER_EID"[NUMBER,22]
    Pls suggest
    s

  • Cannot access ADP payroll Our systems have detected that your internet browser version does not meet the minimum requirements for the ADP EasyPayNet payroll application.

    Not recognized carrier
    need to access to process company payroll

    Is this the complete message that your are seeing? https://easynet.adp.com/net5/badBrowser.html
    If so, read the second paragraph. They may only support IE; if so, that is ADPs choice.
    Have you contacted "your ADP service center" per the message that you posted under More Information?
    You '''''may''''' be able to access the site using Firefox by opening IE in a Firefox tab using the following extension. For safety, using this extension or IE directly, you must have the most current version of IE for system and keep it updated.
    *http://coralietab.mozdev.org/installation.html

  • Can you specify the columns that get written to a spreadsheet when using the query attribute of cfspreadsheet?

    Hello, I wanted to see if you can control which columns from a query get written to a excel spreadsheet. I have some items in my query that I do not want in the spreadsheet but need for my query, if that makes sense.
    Thanks.
    Steve

    There are no parameters in the cfSpreadsheet tag to choose specific columns, however you can use a query of queries (About Query of Queries - ColdFusion English Documentation - Adobe Learning Resources) to get a query object with a subset of columns to pass to the tag.

  • My iphone 4 does not use the gyroscope that came with the ios 7 update. so then how can i get it to work

    I downloaded ios 7 some time ago when it was new and what not. I found out from my friends iphone 4 with ios 7 the wallpaper moved. why doesnt this happen for me?

    That's not a feature of iOS 7 on the iPhone 4. It requires a 4S or higher.

  • I can not use the Acrobat DC Cloud. How do I get an Acrobat PDF Reader that does not use the Cloud?

    The subject pretty much says it all.
    I can not save sensitive corporate files on your Cloud.
    Even for non-sensitive PDFs, I do not always have access to the cloud when I need to view or work with a PDF.
    I need a non-cloud version of Acrobat Reader.
    When Reader DC installed onto my system it must have blown away Reader XI.
    After I uninstalled Reader DC, now I can't open/read PDFs anymore.
    Also, I can't find a copy of Adobe Acrobat to install that isn't cloud dependent.
    This is a problem for me.
    Besides all that, NOW I get error messages every time I try to re-install Reader DC.
    See below.
    So, today at work, I can no longer open PDFs.
    Thanks? NOT!
    HELP!
    Gene

    Here, I finally have a solution.
    Gotta love Google.
    More helpful than Adobe so far.
    Note: Clicking on the link below will immediately open the download dialogue box.
    ftp://ftp.adobe.com/pub/adobe/reader/win/10.x/10.1.1/en_US/AdbeRdr1011_en_US.exe
    I used this download to install, and the Installer was flawless.
    Thanks everyone who contributed ideas and potential solutions.

  • Why isn't my query using the index?

    I have a query that inserts values for engines in a grid; it uses a static date table to determine the day in week, or
    week in year (depending on different standards, the DBA can configure this table to their business's likings). I have
    two indexes on this table:
    create table d_date (
         date_key number(5) not null,
         sql_calendar_date timestamp(3) null,
         year_id number(5) null,
         month_id number(3) null,
         day_id number(3) null,
         year_end_biz_date timestamp(3) null,
         qtr_end_biz_date timestamp(3) null,
         month_end_biz_date timestamp(3) null,
         week_end_biz_date timestamp(3) null,
         quarter_id number(3) null,
         week_id number(3) null,
         day_in_year number(5) null,
         day_in_month number(3) null,
         day_in_week number(3) null,
         month_name char(3) null,
         day_in_week_name char(3) null,
         month_type_code char(1) null,
         week_type_code char(1) null,
         date_type_code char(1) null,
         weekend_flag char(1) null,
         holiday_flag char(1) null,
         from_datetime timestamp(3) null,
         to_datetime timestamp(3) null,
         current_flag char(1) null,
         constraint d_date_pkey primary key (date_key)
         ) tablespace dim;
    create index d_date_dy on d_date(year_id, day_in_year) tablespace_dim_idx;
    create index d_date_ww on d_date(year_id, week_id) tablespace_dim_idx;Now, when I run a query to insert the week id into a table based on two values, the year_key and day_in_year_key,
    it should use the d_date_dy index correct?
    Here is what the query looks like:
    INSERT INTO F_ENGINE (YEAR_KEY,MONTH_KEY,WEEK_IN_YEAR_KEY,DAY_IN_YEAR_KEY,DAY_IN_MONTH_KEY,HOUR_IN_DAY_KEY, Q_HOUR_IN_DAY_KEY,
      GRID_KEY,ENGINE_KEY,TIME_STAMP,ENGINE_CPU_UTIL,ENGINE_CPU_GRID_UTIL,MEMORY_TOTAL_BYTE, MEMORY_FREE_BYTE,DISK_FREE_MEGABYTE,
      PROCESS_COUNT,ENGINE_ID,GRID_ID,GRID_NAME,BATCH_ID,RECORD_VIEWABLE_F)
    SELECT EXTRACT(YEAR FROM START_DATETIME),EXTRACT(MONTH FROM START_DATETIME), DD.WEEK_ID,
      TO_NUMBER(TO_CHAR(START_DATETIME, 'DDD')), EXTRACT(DAY FROM START_DATETIME),EXTRACT(HOUR FROM START_DATETIME),
      FLOOR(EXTRACT(MINUTE FROM START_DATETIME)/15)*15,DG.GRID_KEY,DE.ENGINE_KEY, START_DATETIME,CPU_UTIL,DS_CPU,MEMORY,
      FREE_MEMORY,FREE_DISK,PROCESSES,ID,PE.GRID,DG.GRID_NAME,:B1 ,1
    FROM P_ENGINE PE, D_GRID DG, D_ENGINE DE, D_DATE DD
    WHERE PE.GRID = DG.GRID_ID AND DG.CURRENT_FLAG = 'Y' AND PE.ID = DE.ENGINE_ID AND DE.GRID_KEY = DG.GRID_KEY AND
      DE.CURRENT_FLAG = 'Y' AND PE.BATCH_ID = :B1 AND DD.YEAR_ID = EXTRACT(YEAR FROM START_DATETIME) AND
    DD.DAY_IN_YEAR = TO_NUMBER(TO_CHAR(START_DATETIME,'DDD'))
    ORDER BY EXTRACT(YEAR FROM START_DATETIME),EXTRACT(MONTH FROM START_DATETIME),
      EXTRACT(DAY FROM START_DATETIME),EXTRACT(HOUR FROM START_DATETIME),FLOOR(EXTRACT(MINUTE FROM START_DATETIME)/15)*15,
      DG.GRID_KEY,DE.ENGINE_KEY
    Here is the explain plan:
    Operation Object Object Type Order Rows Size (KB) Cost Time (sec) CPU Cost I/O Cost
    INSERT STATEMENT
    SORT ORDER BY
         HASH JOIN
           HASH JOIN
             HASH JOIN
              TABLE ACCESS FULL D_GRID TABLE 1 2 0.316 3 1 36887 3
              TABLE ACCESS FULL D_ENGINE TABLE 2 10 0.410 3 1 42607 3
             PARTITION LIST SINGLE   5 1434 344.496 9 1 2176890 9
              TABLE ACCESS FULL P_ENGINE TABLE 4 1434 344.496 9 1 2176890 9
                TABLE ACCESS FULL D_DATE TABLE 7 7445 283.550 19 1 3274515 18Now it is obviously not using the index for the d_date table since it is doing a full table access.
    Does this have something to do with the fact that I am using extract(), to_number(), to_char() functions in my WHERE clause that it is not allowing the use of the index?
    Any help would be greatly appreciated. Thanks.
    -Tim

    It's difficult to tell just from this. For one thing, you didn't post your query using the forum format tags, so it's hard to read and you didn't post your Oracle version.
    In the query, you don't always prefix columns with the table alias. That makes it impossible for us (and maintainers of this code) to know at a glance which table a column is in.
    It's possible that performing functions on a column will disable the index. Do your other tables have indexes? Do you have updated statistics on all the tables?
    The main reason the optimizer will not use an index is because it thinks it cheaper not to.

  • Why my query not using any index but doing a FULL TABLE SCAN

    Hi,
    My EXPLAIN PLAN output is
    Plan hash value: 1163866984                                                                                                                                                                                                                                                                                 
    | Id  | Operation               | Name              | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |                                                                                                                                                                                                       
    |   0 | SELECT STATEMENT        |                   |   774 |   159K|       | 40847   (2)| 00:08:11 |                                                                                                                                                                                                       
    |*  1 |  FILTER                 |                   |       |       |       |            |          |                                                                                                                                                                                                       
    |   2 |   SORT GROUP BY         |                   |   774 |   159K|       | 40847   (2)| 00:08:11 |                                                                                                                                                                                                       
    |*  3 |    HASH JOIN            |                   | 77337 |    15M|  9744K| 40843   (2)| 00:08:11 |                                                                                                                                                                                                       
    |*  4 |     HASH JOIN           |                   | 77337 |  8836K|  5896K| 20987   (2)| 00:04:12 |                                                                                                                                                                                                       
    |*  5 |      HASH JOIN          |                   | 77337 |  4984K|       |  9292   (3)| 00:01:52 |                                                                                                                                                                                                       
    |*  6 |       HASH JOIN         |                   | 24991 |   951K|       |  3349   (3)| 00:00:41 |                                                                                                                                                                                                       
    |*  7 |        TABLE ACCESS FULL| IDS_TXNIDNUMBERS  | 24991 |   683K|       |  2328   (3)| 00:00:28 |                                                                                                                                                                                                       
    |   8 |        TABLE ACCESS FULL| IDS_TXNDEMDATAMAP |  2419K|    25M|       |  1006   (3)| 00:00:13 |                                                                                                                                                                                                       
    |   9 |       TABLE ACCESS FULL | IDS_IDNUMBERS     |  7435K|   191M|       |  5903   (2)| 00:01:11 |                                                                                                                                                                                                       
    |  10 |      TABLE ACCESS FULL  | IDS_DEMDATA       |  2583K|   125M|       |  3683   (5)| 00:00:45 |                                                                                                                                                                                                       
    |  11 |     TABLE ACCESS FULL   | IDS_TXN           |  2583K|   231M|       |  6403   (1)| 00:01:17 |                                                                                                                                                                                                       
    -----------------------------------------------------------------------------------------------------  All my 5 tables IDS_TXNIDNUMBERS, IDS_TXNDEMDATAMAP, IDS_IDNUMBERS,IDS_DEMDATA, IDS_TXN has indexes in relevant columns. Is it cause less time so CBO is not using the indexes.
    Thanks
    Amitava.

    amitavachatterjee1975 wrote:
    Please be polite when responding to my queries. If you find these questions not to your standard, stay away from them. This is an open forum and I have got my full rights to ask questions.Unsure, what wrong did you find in SB's reply. I find those links perfectly knowledgeable. The question of having so many unanswered questions probably pricked you a little too much. But that, IMO, is a legitimate question, to be asked to a User who even after being associated with OTN for over an year has 100% record of not getting an answer.
    For your original question, you will have to provide more details to allow people to answer you.
    You must read {message:id=3292438} and post the mentioned details. People do not carry a Crystal Ball to identify the problem merely by reading few lines of Problem description and Explain plans. Do not make people guess, provide appropriate details, to help them Help "You".

Maybe you are looking for

  • Check on use of Precalculated queries

    Hello, could you tell me if exist a way to check if the queries run batch ( throurg the Reporting Agent, with web Template ) are downloaded by the user? My problem is: the users donwload the query run thourgh the Reporting Agent ? Thanks !!

  • EXPORT - IMPORT in BACKGROUND JOB

    Hello ABAP Gurus, There are two programs I am using. In 1st Program I am Exporting the Data to the ABAP Memory and then after that scheduling the second program in background from 1st Program through 1 ) JOB_OPEN 2 ) SUBMIT 3 ) JOB_CLOSE Now I am try

  • Error when passing data through Business connector

    Dear all, we are getting below exception in BC trace while connecting to the remote url through SAP BC. Please guide us how to solve this problem. java.lang.RuntimeException: iaik.security.ssl.SSLCertificateException: Peer certificate rejected by Tru

  • Vanished DFS user rights

    Greetings, today several users reported missing files and folders. A look in the secruity settings showed, that all user permissions, except the ones from the administrator group, have been vanished. After adding the specific user / group again, the

  • Windows 8 RTM bits officially coming soon

    Windows 8 RTM for IT Pros and developers will be coming August 15th (via Technet and MSDN). I wonder if Lenovo officially supports upgrading our PCs to Windows 8 then. I have the A720 and mysteriously, the C: drive is the larger, HDD whereas the D: d