Index isn't used

Hello
This request doesn't use an index although it's suitable
SELECT *
FROM oebs
where existsNode(OBJECT_VALUE, '/o:root/c:content/c:organization[org:organization_id=500]', 'xmlns:ora="http://xmlns.oracle.com/xdb" xmlns:o="http://www.rosbank.ru/oebs" xmlns:c="http://www.rosbank.ru/oebs/content/organization" xmlns:org="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/appsxx_organization_v"') > 0;
or
SELECT *
FROM oebs
where extractValue(OBJECT_VALUE, '/o:root/c:content/c:organization/org:organization_id', 'xmlns:ora="http://xmlns.oracle.com/xdb" xmlns:o="http://www.rosbank.ru/oebs" xmlns:c="http://www.rosbank.ru/oebs/content/organization" xmlns:org="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/appsxx_organization_v"') = 500;
Here are two indexes which are possible to use:
CREATE INDEX oebs_org_org_id_extract_index
ON oebs (extractValue(OBJECT_VALUE, '/o:root/c:content/c:organization/org:organization_id', 'xmlns:ora="http://xmlns.oracle.com/xdb" xmlns:o="http://www.rosbank.ru/oebs" xmlns:c="http://www.rosbank.ru/oebs/content/organization" xmlns:org="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/appsxx_organization_v"'));
CREATE INDEX oebs_org_org_id_extract_index2
ON ORGANIZATION (extractValue(OBJECT_VALUE, '/c:organization/org:organization_id', 'xmlns:c="http://www.rosbank.ru/oebs/content/organization" xmlns:org="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/appsxx_organization_v"'));
These are the indexes how they are stored in DB:
CREATE INDEX XML_DB_TESTS_10G.OEBS_ORG_ORG_ID_EXTRACT_INDEX ON XML_DB_TESTS_10G.OEBS
(EXTRACTVALUE(SYS_MAKEXML('412098D123764284A04106081FA28D46',4655,"XMLEXTRA","XMLDATA"),'/o:root/c:content/c:organization/org:organization_id','xmlns:ora="http://xmlns.oracle.com/xdb" xmlns:o="http://www.rosbank.ru/oebs" xmlns:c="http://www.rosbank.ru/oebs/content/organization" xmlns:org="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/appsxx_organization_v"'))
LOGGING
TABLESPACE USERS
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
NOPARALLEL;
CREATE INDEX XML_DB_TESTS_10G.OEBS_ORG_ORG_ID_EXTRACT_INDEX2 ON XML_DB_TESTS_10G.ORGANIZATION
("XMLDATA"."organization_id")
LOGGING
TABLESPACE USERS
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
NOPARALLEL;
And here is the result:
TABLE ACCESS,FULL,,XML_DB_TESTS_10G,OEBS
filter predicates:
SYS_CHECKACL("ACLOID","OWNERID",xmltype('<privilege xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-properties/><read-contents/></privilege>'))=1 AND EXISTSNODE(SYS_MAKEXML('412098D123764284A04106081FA28D46',4655,"OEBS"."XMLEXTRA","OEBS"."XMLDATA"),'/o:root/c:content/c:organization[org:organization_id=500]','xmlns:ora="http://xmlns.oracle.com/xdb" xmlns:o="http://www.rosbank.ru/oebs" xmlns:c="http://www.rosbank.ru/oebs/content/organization" xmlns:org="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/appsxx_organization_v"')>0
SYS_CHECKACL("ACLOID","OWNERID",xmltype('<privilege xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-properties/><read-contents/></privilege>'))=1 AND TO_NUMBER(EXTRACTVALUE(SYS_MAKEXML('412098D123764284A04106081FA28D46',4655,"OEBS"."XMLEXTRA","OEBS"."XMLDATA"),'/o:root/c:content/c:organization/org:organization_id','xmlns:ora="http://xmlns.oracle.com/xdb" xmlns:o="http://www.rosbank.ru/oebs" xmlns:c="http://www.rosbank.ru/oebs/content/organization" xmlns:org="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/appsxx_organization_v"'))=500
The table has 10000 records but only one of them satisfies the query condition.
Similar requests were working in the past but I had made some changes so it isn't working now.
Could anybody tell me what is wrong?
Thanks
Dmitry

Hello
This is Dmitry again
I found a mistake in my request. The "organization_id" has a string type so I need to use next query:
SELECT *
FROM oebs
where extractValue(OBJECT_VALUE, '/o:root/c:content/c:organization/org:organization_id', 'xmlns:ora="http://xmlns.oracle.com/xdb" xmlns:o="http://www.rosbank.ru/oebs" xmlns:c="http://www.rosbank.ru/oebs/content/organization" xmlns:org="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/appsxx_organization_v"') = '500';
Although I had changed another my request, it still doesn't work:
SELECT *
FROM oebs
where existsNode(OBJECT_VALUE, '/o:root/c:content/c:organization[org:organization_id=[b]"500"]', 'xmlns:ora="http://xmlns.oracle.com/xdb" xmlns:o="http://www.rosbank.ru/oebs" xmlns:c="http://www.rosbank.ru/oebs/content/organization" xmlns:org="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/appsxx_organization_v"') > 0;
SYS_CHECKACL("ACLOID","OWNERID",xmltype('<privilege xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-properties/><read-contents/></privilege>'))=1 AND EXISTSNODE(SYS_MAKEXML('412098D123764284A04106081FA28D46',4655,"OEBS"."XMLEXTRA","OEBS"."XMLDATA"),'/o:root/c:content/c:organization[org:organization_id="500"]','xmlns:ora="http://xmlns.oracle.com/xdb" xmlns:o="http://www.rosbank.ru/oebs" xmlns:c="http://www.rosbank.ru/oebs/content/organization" xmlns:org="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/appsxx_organization_v"')>0
What is the difference between the last request which doesn't use an index and another one which does it?
Thanks
Dmitry

Similar Messages

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

  • Why is index not being used?

    I need some help in trying to work out why an index isn't being used. I hope someone here can help.
    Table definition for ACT_TOTALS includes
    STARTTIME TIMESTAMP(6)
    There is an index on to_char(starttime, 'YYYY-MM-DD HH24')
    There is a vew definition ACT_TOTALS_HOURLY2 which includes
    select to_char(starttime, 'YYYY-MM-DD HH24') STARTTIMSE
    from ACT_TOTALS
    group by to_char(starttime, 'YYYY-MM'DD HH24'), TRANSTYPE
    I have run a query
    select starttime from ACT_TOTALS_HOURLY2
    where starttime <= to_char(sysdate, 'YYYY-MM-DD HH24');
    The table access comes out as full despite there being > 2 million rows in the table.
    The predicate looks like
    TO_CHAR(INTERNAL_FUNCTION(''STARTTIME''), 'YYYY-MM-DD HH24')<= ..........
    I thinkg the INTERNAL_FUNCTION is an implicit cast from DATE to TIMESTAMP.
    Can anyone please throw any light on why the index on the table wouldn't be used in this case?
    Thanks in advance for any help.

    Can you supply a test case for that?
    This is what I have done to engeneer your case
    drop table t1;
    create table t1 (n1 number, d1 date, STARTTIME TIMESTAMP(6));
    insert into t1(n1,d1, starttime)  select rownum, trunc(sysdate) + rownum, sysdate
    from dual connect by level <= 2e6;
    create or replace view t1_v as select n1, d1, to_char(starttime, 'YYYY-MM-DD HH24') starttimse
    from t1;
    SQL> explain plan for
      2  select starttimse from t1_v
      3  where starttimse <= to_char(sysdate, 'YYYY-MM-DD HH24');
    Explained.
    SQL> select * from table(dbms_xplan.display);
    Plan hash value: 838529891
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |   109K|  1394K|  2004  (14)| 00:00:12 |
    |*  1 |  TABLE ACCESS FULL| T1   |   109K|  1394K|  2004  (14)| 00:00:12 |
    Predicate Information (identified by operation id):
       1 - filter(TO_CHAR(INTERNAL_FUNCTION("STARTTIME"),'YYYY-MM-DD
                  HH24')<=TO_CHAR(SYSDATE@!,'YYYY-MM-DD HH24'))
    Note
       - dynamic sampling used for this statement
    SQL> create index t1_ind on t1 (to_char(starttime, 'YYYY-MM-DD HH24'));
    Index created.
    SQL> explain plan for
      2  select starttimse from t1_v
      3  where starttimse <= to_char(sysdate, 'YYYY-MM-DD HH24');
    Explained.
    SQL> select * from table(dbms_xplan.display);
    Plan hash value: 3884685049
    | Id  | Operation        | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT |        |   109K|  1394K|    68   (2)| 00:00:01 |
    |*  1 |  INDEX RANGE SCAN| T1_IND |   109K|  1394K|    68   (2)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - access(TO_CHAR(INTERNAL_FUNCTION("STARTTIME"),'YYYY-MM-DD
                  HH24')<=TO_CHAR(SYSDATE@!,'YYYY-MM-DD HH24'))
    Note
       - dynamic sampling used for this statement
    The above selects are done against the view t1_v.
    While the following one is done against the table t1
    SQL> set autotrace traceonly explain
    SQL> select starttime from t1
      2  where starttime <= to_char(sysdate, 'YYYY-MM-DD HH24');
    Execution Plan
    Plan hash value: 838529891
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      | 29875 |   379K|  1790   (4)| 00:00:11 |
    |*  1 |  TABLE ACCESS FULL| T1   | 29875 |   379K|  1790   (4)| 00:00:11 |
    Predicate Information (identified by operation id):
       1 - filter("STARTTIME"<=TO_TIMESTAMP(TO_CHAR(SYSDATE@!,'YYYY-MM-DD
                  HH24')))
    If you can post a clear test case of your issue may be one of us can help you
    Best regards
    Mohamed Houri
    www.hourim.wordpress.com

  • What is RID in non clustered index and its use

    Hi All,
    I need help regarding following articles on sql server
    1) what is RID in non clustered index and its use.
    2) What is Physical and virtual address space. Difference in 32 bit vs 64 bit Virtual address space
    Regards
    Rahul

    Next time Please ask single question in a thread you will get better response.
    1. RID is location of heap. When you create Non clustered index on heap and
    lookup happens to get extra records RID is used to locate the records. RID is basically Row ID. This is basic definition for you. Please read
    this Thread for more details
    2. I have not heard of Physical address space. I Know Virtual address space( VAS)
    VAS is simple terms is amount of memory( virtual )  'visible' to a process, a process can be SQL Server process or windows process. It theoretically depends on architecture of Operating System. 32 bit OS will have maximum range of 4 G VAS, it's calculated
    like a process ruining on 32 bit system can address max up to 2^32 locations ( which is equivalent to 4 G). Similarly for 64 bit max VAS will be 2^64 which is theoretically infinite. To make things feasible maximum VAS for 64 bit system is kept to 8 TB. Now
    VAS acts as layer of abstraction an intermediate .Instead of all request directly mapping to physical memory it first maps to VAS and then mapped to physical memory so that it can manage request for memory in more coordinated fashion than allowing process
    to do it ,if not it will  soon cause memory crunch.Any process when created on windows will see virtual memory according to its VAS limit.
    Please read
    This Article for detailed information
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
    My Technet Wiki Article
    MVP

  • My old computer (a Sony) with my iTunes crashed. I have a new MAC and want to make sure I can keep all of my music (mostly from old CD's that have been lost). I bought iTunes match hoping that would work but it isn't using the data on my phone. HELP!

    My old computer (a Sony) with my iTunes crashed. I have a new MAC and want to make sure I can keep all of my music (mostly from old CD's that have been lost). I bought iTunes match hoping that would work but it isn't using the data on my phone. HELP!

    Since you have purchased a new Mac (which, BTW, is not typed in all capitals) why not buy a Time Capsule <http://www.apple.com/airport-time-capsule/> which is designed specifically to work with OS X and Time Machine?
    You don't say what part of your Sony "crashed." If it was not the HDD it is possible to take the computer apart, put the HDD in an external case, then recover the data off of it (including the music) simply drag-n-drop. If it was the HDD that "crashed" that makes it more difficult.
    If you are able to recover the music from the Sony you can then add it to the iTunes library on the Mac and iTunes Match will then scan, match and upload the tracks to be mirrored in the cloud.

  • Index not getting used in spite of hints

    Its Oracle 10g Release 10.2.0.4.0 Hi All,
    I have this query in which there is are indexes on Intrument table like this:
    Instrument:
    idx 1 : (INSTRUMENT_ID, END_COB_DATE, CLOSE_ACTION_ID, PRODUCT_SUB_TYPE_ID, BEGIN_COB_DATE)
    idx 2 : ( INSTRUMENT_ID, INSTRUMENT_VN, END_COB_DATE, CLOSE_ACTION_ID)
    idx 3 : (CLOSE_ACTION_ID, END_COB_DATE)I tried all the possible ways but none of the indexes are getting used causing full table scans of this table. I need some guidance on how can I avoid this FTS so the query can run fast and use the index on Instrument table:
    query:
    select distinct i.instrument_id,
                    i.name,
                    case
                      when (mn2.display_name != 'DEBT PRIORITY CLASS' and
                           mn2.display_name is not null) then
                       mn2.display_name
                      else
                       mn1.display_name
                    end "DEBT_PRIORITY_CLASS"
      from instrument i, inst_debt id
      left join marsnode mn1 on (id.debt_priority_class_id = mn1.node_id and
                                mn1.close_date is null and
                                mn1.type_id = 58412926883279)
      left join marsnodelink mnl1 on (mn1.node_id = mnl1.node_id and
                                     mnl1.close_date is null and
                                     mnl1.begin_cob_date <=
                                     TO_DATE('27-Oct-2010', 'DD-Mon-YYYY') and
                                     mnl1.end_cob_date >
                                     TO_DATE('27-Oct-2010', 'DD-Mon-YYYY'))
      left join marsnode mn2 on (mnl1.parent_id = mn2.node_id and
                                mn2.close_date is null and
                                mn2.type_id = 58412926883279)
    where i.instrument_id = id.instrument_id
       and i.instrument_vn = id.instrument_vn
       AND i.end_cob_date > TO_DATE('27-Oct-2010', 'DD-Mon-YYYY')
       AND i.close_action_id is null
       AND i.product_sub_type_id = 3
       AND i.begin_cob_date <= TO_DATE('27-Oct-2010', 'DD-Mon-YYYY')This is the execution plan
    | Id  | Operation                       | Name              | Rows  | Bytes |TempSpc| Cost (%CPU)|
    |   0 | SELECT STATEMENT                |                   |  2026K|   407M|       |   509K (20)|
    |   1 |  HASH UNIQUE                    |                   |  2026K|   407M|   879M|   509K (20)|
    |*  2 |   HASH JOIN RIGHT OUTER         |                   |  2026K|   407M|       |   426K (23)|
    |*  3 |    TABLE ACCESS BY INDEX ROWID  | MARSNODE          |   501 | 23046 |       |   239   (3)|
    |*  4 |     INDEX RANGE SCAN            | FKI_38576_TYPE_ID | 10159 |       |       |    34   (6)|
    |*  5 |    HASH JOIN RIGHT OUTER        |                   |  2026K|   318M|       |   425K (23)|
    |*  6 |     TABLE ACCESS FULL           | MARSNODELINK      |   330 | 15510 |       |  6560  (16)|
    |*  7 |     HASH JOIN RIGHT OUTER       |                   |  2026K|   228M|       |   419K (23)|
    |*  8 |      TABLE ACCESS BY INDEX ROWID| MARSNODE          |   501 | 23046 |       |   239   (3)|
    |*  9 |       INDEX RANGE SCAN          | FKI_38576_TYPE_ID | 10159 |       |       |    34   (6)|
    |* 10 |      HASH JOIN                  |                   |  2026K|   139M|    34M|   418K (23)|
    |  11 |       TABLE ACCESS FULL         | INST_DEBT         |  1031K|    22M|       |  1665  (30)|
    *|* 12 |       TABLE ACCESS FULL         | INSTRUMENT        |  2062K|    96M|       |   413K (23)|*
    --------------------------------------------------------------------------------------------------predicate info
    2 - access("MNL1"."PARENT_ID"="MN2"."NODE_ID"(+))
    3 - filter("MN2"."CLOSE_DATE"(+) IS NULL)
    4 - access("MN2"."TYPE_ID"(+)=58412926883279)
    5 - access("MN1"."NODE_ID"="MNL1"."NODE_ID"(+))
    6 - filter("MNL1"."CLOSE_DATE"(+) IS NULL AND "MNL1"."END_COB_DATE"(+)>TO_DATE('
                2010-10-27 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "MNL1"."BEGIN_COB_DATE"(+)<=TO_DATE('
                2010-10-27 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
    7 - access("ID"."DEBT_PRIORITY_CLASS_ID"="MN1"."NODE_ID"(+))
    8 - filter("MN1"."CLOSE_DATE"(+) IS NULL)
    9 - access("MN1"."TYPE_ID"(+)=58412926883279)
    10 - access("I"."INSTRUMENT_ID"="ID"."INSTRUMENT_ID" AND
                "I"."INSTRUMENT_VN"="ID"."INSTRUMENT_VN")
    12 - filter("I"."PRODUCT_SUB_TYPE_ID"=3 AND "I"."CLOSE_ACTION_ID" IS NULL AND
                "I"."END_COB_DATE">TO_DATE(' 2010-10-27 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
                "I"."BEGIN_COB_DATE"<=TO_DATE(' 2010-10-27 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))Regards,
    Aashish

    Aashish S. wrote:
    I tried all the possible ways but none of the indexes are getting used causing full table scans of this table. I need some guidance on how can I avoid this FTS so the query can run fast and use the index on Instrument table:I assume the last part of the above statement is what you actually need to achieve (i.e. improve execution time of the query) and the query not using index is what you think the "cause" for the actual "problem". I will try to answer the actual "problem". Based on what you have posted, some observations/suggestions
    1) Your plan shows the query is expected to retrieve 2026K rows. Are you sure you need to retrieve that many records? You may want to revisit the "requirement" here.
    2) Continuing above point, you may want to post details of how much time the query is taking to execute at present and how much time do you expect it to take. Another most important details will be how are you measuring the query execution time. With that huge number of records, it is quite possible that more time is being spent in just transferring the query results to the "client" than actual time taken by server to execute the query.
    3) If what you have posted is the order of columns in the indexes on INSTRUMENT table, then which index do you think will help the query execution and how? The order of columns suggest that none of the indexes will be good enough and that seems to be the right choice.
    4) Your predicate section states that filter predicate on INSTRUMENT table generates 2062K rows. How many records exist in INSTRUMENT table? You will need to have many times more records (besides other factors like ordering of table data etc.) in the table to justify the indexed access to fetch these huge number of rows.
    5) Finally, you may want to verify whether the statistics on tables and indexes used by the query are up-to-date.
    Hope this helps.

  • Index not being used in Select statement

    Friends
    I have the following SQL statement:
    SELECT
    a.acct,
    a.date_field,
    UPPER(b.feegroup) feegrp,
    SUM (a.fee1) fee1,
    SUM (a.fee2) fee2,
    SUM (a.fee3) fee3
    FROM table1 a, table2 b
    WHERE 1 = 1
    AND a.fee_id = b.fee_id
    GROUP BY a.acct, a.date_field, b.feegroup;
    Both the tables have index on fee_id column. When I run the explain plan for this statement, I am getting the following output:
    Operation | Option | Object Name | Position
    SELECT STATEMENT | | | 560299
    HASH | GROUP BY| |1
    TABLE ACCESS | FULL| table2 | 1
    TABLE ACCESS | FULL| table1 | 2
    Why Oracle is not using the index?
    Edited by: darshilm on Dec 10, 2009 3:56 PM

    The proposed plan is the optimal according to your current conditions in the "where clause" where you have only the equality join condition and therefore the CBO can use HASH JOIN. Using any kind of index access would just increase the amount of required work unless you would add some very restrictive conditions which will select rows from relatively small amount of blocks. Here I have to mention that what really counts in the CBO cost calculation is the amount of blocks accessed and not the number of rows. The "currency" for I/O in Oracle is a block and not a row. CBO always uses an assumption that there is nothing in the buffer cache and it will have to perform a physical read for every block.
    How many blocks will actually be accessed depends on the data distribution. It can happen that every single row that you have to retrieve resides in a different block and although you access only 1000 rows out of a million row table you would have to visit almost every block of that table. For such a situation a FULL TABLE SCAN is the best access path and Oracle will use multiblock I/O for that. On the other side you can have those 1000 rows only in a few blocks and then the index access would be the most appropriate one. For index access Oracle uses single block I/O. Usually the actual situation is somewhere between this two extreme situations. But you can run some tests by yourself and see when an index access will be replaced by a full table scan while you will make your predicates less selective.
    HTH, Joze
    Co-author of the forthcoming book "Expert Oracle Practices"
    http://www.apress.com/book/view/9781430226680
    Oracle related blog: http://joze-senegacnik.blogspot.com/
    Blog about flying: http://jsenegacnik.blogspot.com/
    Blog about Building Ovens, Baking and Cooking: http://senegacnik.blogspot.com

  • Index is not used (why and what should i do) table too big

    hi guys,
    having a headache now. (on 10gR2 on linux system)
    I used to have a large table and this is how i managed it. (i am on standard edition (thus i have no partitioning)
    i would have a
    1) cron job run daily to keep track of the lowest and highest ID of the table PER MONTH (inserted into a table)
    2) below is the table
    CDR     MONTH     01-AUG-11 00:00:00     94118236     97584656
    CDR     MONTH     01-SEP-11 00:00:00     97581362     100573669
    CDR     MONTH     01-OCT-11 00:00:00     100570865     103631203
    CDR     MONTH     01-NOV-11 00:00:00     103629760     106497084
    CDR     MONTH     01-DEC-11 00:00:00     106494085     107306335
    so as you can see, for the month of dec for example, the lowest CDR is 10649408 and the highest is 107306335.
    3) so everytime i write a sql on this table if i want to get data for NOV
    select * from cdr where ID >= get_cdr_id('CDR','NOV','SMALLEST');
    and it would be
    select * from cdr where ID >= 103629760;
    In the past, the index will be used (index range scan), but now the optimiser is doing a FTS and is taking too much time.
    therefore i went to force the index
    select /*+INDEX(C, CDR_PK)*/* from cdr C where cdr_id > 103629760 and cdr_id < 106497084;
    and the COST -> 1678927 (CDR, INDEX_ROWID)
    13158 (CDR_PK, RANGE SCAN)
    -- the result return is fast and good.
    without the index
    select * from cdr C where cdr_id > 100570865 and cdr_id < 103631203
    the COST -> 440236 (CDR,FULL)
    -- but the result return is slow like anything
    My question is
    1) which cost should i look at ?
    the one with index hint have much higher COST, but the results return are so FAST.
    1678927 (with hint) compare with 440236 (FTS)
    2) is using the index is the correct way, why isnt my optimiser using it ?! how do i make the optimiser used it ?
    Regards,
    Noob

    Iordan Iotzov wrote:
    About the clustering factor– I think there are two possibilities:
    1) The “clustering factor” is generally correct, i.e. it represents the true value of how the data is “scattered” through the table. The clustering factor for the fragment of data you are interested in (where cdr_id > 100570865 and cdr_id < 103631203), however, is different (smaller).
    2)Oracle did not compute the “clustering factor” correctly. It is not uncommon occurrence, particularly in 10g. This blog entry by Randolf Geist is quite informative - http://oracle-randolf.blogspot.com/2010/01/clusteringfactor-what-if-analysis.html. Comprehensive information on that topic is available in Jonathan Lewis’ book Cost Based Oracle Fundamentals (chapter 5).
    You can make the index more attractive by setting lower “clustering factor” value using DBMS_STATS.SET_INDEX_STATS. If you choose to do that, you should review your whole stats gathering procedure, because the next gathering would most likely reset the “clustering factor” to its old (high) value.
    Iordan Iotzov
    http://iiotzov.wordpress.com/

  • 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

  • My daughter's phone racks up data usage every 12 hours, twice a day, even though she isn't using it. Anybody know why this would be happening or how to track it/stop it?

    My daughter's phone racks up data usage every 12 hours, twice a day, even though she isn't using it. Anybody know why this would be happening or how to track it/stop it?

        Its all good, TimN8128! Mrhelper is corret with regards to making sure that mobile data is turned off when on WiFi or when not connected to WiFi, if you do not want the phone to access data services to update or refresh app services. These applications can all be configured by going to Settings and reviewing all apps that appear in that area. You can also configure a bit further by going to Settings>Cellular.
    NicandroN_VZW
    Follow us on twitter @VZWSupport

  • HT2736 Now, I've reset my iPad and I can't use my account because it says my account isn't used in itune store.

    I've already reedeemed my itune account and used it. Now, I've reset my iPad and I can't use my account because it says my account isn't used in itune store. What's the problem and how can I solve it? Please.

    I'm at home now and have my notes. Creative Cloud had been uninstalled before my practically brand new Dell was restored with the factory backup disks on 12-18 (a whole nother story). CS6 was installed AFTER the restore, so I don't see how any parts and pieces of Creative Cloud could still be on my hard drive.
    On 12-22 I received this Acrobat error: "A problem has occurred with the licensing of this product. Restart your computer and relaunch the product. Error: 130:11." Restarting did not help, so I uninstalled and reinstalled Acrobat from my DVD, and it worked. I also updated it, just in case. I only turned the computer on a few times after that (not using Acrobat) until the 29th, when Acrobat started telling me I needed to renew my Creative Cloud subscription. That's when the Adobe techs told me I need to get a new email address because CS6 and Creative Cloud share the same email address. ALL of my Adobe products have been used with that same email.
    So tonight, with your advice, here's my update. CS6 listed in the Programs and Features control panel included Acrobat, but Acrobat was also listed separately. I uninstalled the one listed separately. I attempted to use the CC Cleaner Tool after that, but the only option for removing Creative Cloud programs was combined with CS6 programs (which I have already installed twice), so I opted to skip the CC cleaner.
    Of course after that, I had no Acrobat at all. I installed it again from my DVD and updated, and now I can launch Acrobat (same as on 12-22). So...wish me luck, and I'll let you know how it goes.
    Thanks,
    Mary Ann

  • Index not being used (again)

    Dear All,
    Having real trouble these days with the indexes.
    I have a query below:
    SELECT MAX(A.ID) PRID,TIMEPERIODID,RESOURCEID
                          FROM   TIMESHEET A, TIMEPERIOD B
                          WHERE A.STATUS IN (1,3,4) AND A.ISADJUSTMENT = 0  
                             AND A.timeperiodid = B.id
                             AND TRUNC(B.PSTART)>=TRUNC(NEXT_DAY(SYSDATE-28,'MONDAY'))
                             GROUP BY TIMEPERIODID,RESOURCEID
    The explain plan for this query is as below:
    Plan     COST
    SELECT STATEMENT       2720
    SORT GROUP BY      2720
      HASH JOIN       2520
       TABLE ACCESS FULL TIMEPERIOD     2
       TABLE ACCESS FULL TIMESHEET     2516As you can see, table access full on timesheet table. However, I have an index on timeperiodid column of the table. Despite using it as hint, the index is not being used. Is it that indexes are not used with GROUP BY?
    Please help.
    Thanks,

    and the explain plan:
    Plan
    SELECT STATEMENT  ALL_ROWSCost: 18,747  Bytes: 105  Cardinality: 1                                                    
         34 SORT GROUP BY  Cost: 18,742  Bytes: 105  Cardinality: 1                                               
              33 FILTER                                          
                   21 NESTED LOOPS  Cost: 18,727  Bytes: 105  Cardinality: 1                                     
                        18 HASH JOIN  Cost: 18,722  Bytes: 415  Cardinality: 5                                
                             11 TABLE ACCESS BY INDEX ROWID TIMEENTRY Cost: 14  Bytes: 144  Cardinality: 9                           
                                  10 NESTED LOOPS  Cost: 15,980  Bytes: 15,552  Cardinality: 243                      
                                       8 HASH JOIN  Cost: 15,588  Bytes: 1,344  Cardinality: 28                 
                                            3 HASH JOIN  Cost: 4,050  Bytes: 24,876,930  Cardinality: 829,231            
                                                 1 TABLE ACCESS FULL TEAM Cost: 3,394  Bytes: 879,444  Cardinality: 48,858       
                                                 2 INDEX FAST FULL SCAN NON-UNIQUE TASK2 Cost: 396  Bytes: 11,656,104  Cardinality: 971,342       
                                            7 VIEW index$_join$_003 Cost: 10,376  Bytes: 24,981,984  Cardinality: 1,387,888            
                                                 6 HASH JOIN  Cost: 15,588  Bytes: 1,344  Cardinality: 28       
                                                      4 INDEX FAST FULL SCAN UNIQUE ASSIGNMENT1 Cost: 3,835  Bytes: 24,981,984  Cardinality: 1,387,888 
                                                      5 INDEX FAST FULL SCAN UNIQUE ASSIGNMENT4 Cost: 3,835  Bytes: 24,981,984  Cardinality: 1,387,888 
                                       9 INDEX RANGE SCAN NON-UNIQUE TIMEENTRY5 Cost: 2  Cardinality: 12                 
                             17 VIEW USER25. Cost: 2,741  Bytes: 553,812  Cardinality: 29,148                           
                                  16 SORT GROUP BY  Cost: 2,741  Bytes: 1,107,624  Cardinality: 29,148                      
                                       15 HASH JOIN  Cost: 2,540  Bytes: 1,107,624  Cardinality: 29,148                 
                                            13 TABLE ACCESS BY INDEX ROWID TIMEPERIOD Cost: 1  Bytes: 140  Cardinality: 10            
                                                 12 INDEX RANGE SCAN NON-UNIQUE TIMEPERIOD2 Cost: 1  Cardinality: 2       
                                            14 TABLE ACCESS FULL TIMESHEET Cost: 2,537  Bytes: 12,040,224  Cardinality: 501,676            
                        20 TABLE ACCESS BY INDEX ROWID TIMEPERIOD Cost: 1  Bytes: 22  Cardinality: 1                                
                             19 INDEX UNIQUE SCAN UNIQUE TIMEPERIOD1 Cardinality: 1                           
                   32 NESTED LOOPS  Cost: 5  Bytes: 75  Cardinality: 1                                     
                        29 NESTED LOOPS  Cost: 4  Bytes: 63  Cardinality: 1                                
                             27 NESTED LOOPS  Cost: 2  Bytes: 37  Cardinality: 1                           
                                  25 NESTED LOOPS  Cost: 2  Bytes: 31  Cardinality: 1                      
                                       23 TABLE ACCESS BY INDEX ROWID OBS_TYPES Cost: 1  Bytes: 18  Cardinality: 1                 
                                            22 INDEX UNIQUE SCAN UNIQUE OBS_TYPES_U2 Cardinality: 1            
                                       24 INDEX RANGE SCAN NON-UNIQUE PROJECT_INDX1 Cost: 1  Bytes: 13  Cardinality: 1                 
                                  26 INDEX UNIQUE SCAN UNIQUE PROJECTS_PK Bytes: 6  Cardinality: 1                      
                             28 INDEX RANGE SCAN NON-UNIQUE OBS_ASSOCIATIONS_N3 Cost: 2  Bytes: 26  Cardinality: 1                           
                        31 TABLE ACCESS BY INDEX ROWID OBS_UNITS Cost: 1  Bytes: 12  Cardinality: 1                                
                             30 INDEX UNIQUE SCAN UNIQUE OBS_UNITS_U1 Cardinality: 1                           

  • Index is not used

    I have a simple query to select from a huge table and where clause has a function to return a single value like this:
    select id from tab where status=get_status(flag);
    However, it's doing a full-table scan which cause problem for us. If I replace the function with a value or add a hint, then it's using indexes:
    select id from tab where status='L'; or select /*+ index (tab, status) */ id from tab where status=get_status(flat);
    What could be the cause of the index not being used in the original query?

    I suppose that 'flag' is a column in the table. If so then a full table scan (or full index scan) will probably be the fastest method to get the result.
    You could try to create an index on a function like
    decode(status,get_status(flag),1,null)and then have
    decode(status,get_status(flag),1,null)=1in your where clause.
    One peace of warning: if status is NULL and get_status(flag) also is null then this function will 1 and not null.

  • Index not getting used

    Hi,
    Oracle version 10g
    I have created a partitioned table and it has the below columns:
    The table is partitioned on the created_date.
    How data gets inserted into this table:
    we have a staging table which will get first populated and then using Exchange partitionis populated.
    statement which populates rel_table
    ' ALTER TABLE ' || table1 ||
    ' EXCHANGE PARTITION ' ||partitionname ||
    ' WITH TABLE ' || table2 ||
    ' WITH VALIDATION UPDATE GLOBAL INDEXES';
    after exchange partition the indexs gets rebuild
    The table would have millions of records.
    Now if i issue a query
    plz help...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    But the indexed column is used in the join, so the index should get used right?Not necessarily. How many rows are in the table? How many rows have that column > 0?
    Please read these:
    When your query takes too long
    When your query takes too long ...
    How to Post a SQL statement tuning request
    HOW TO: Post a SQL statement tuning request - template posting

  • Newly created index not being used

    Hello friends,
    I am observing that a newly created index on a z table with mandt & a new field is not being used. I have already rebuild index & updated stats for table.
    when we query on this table with where clause having same 2 fields mandt & other.. we expected this index to be used. This table is very large. What more i can do now ?
    In trace/SQL session, we can see it is going full table scan.. and takes very long time.
    this new field contain no data as of now for all existing rows. Is this the reason ? or sometihng else ?
    SQL Statement
    SELECT
    FROM
      "ABSA"
    WHERE
      "MANDT" = :A0 AND "ZABCD" = :A1
    Execution Plan
    Explain from v$sql_plan not possible ->  Explain from PLAN_TABLE is displayed !
    No values in v$sql_plan for Address: 0000000166710240 Hash_value:  3891403872 Child_number:  0 Sql_id:
    SELECT STATEMENT ( Estimated Costs = 905.739 , Estimated #Rows = 110.190.667 )
            1 TABLE ACCESS FULL ZABSA
              ( Estim. Costs = 905.739 , Estim. #Rows = 110.190.667 )
              Estim. CPU-Costs = 152.614.535.266 Estim. IO-Costs = 899.784
              Filter Predicates
    NONUNIQUE  Index   ZABSA~Z01
    Column Name                     #Distinct
    MANDT                                          1
    ZABCD                                         1
    thanks & regards
    ashish
    Edited by: ashish vikas on Mar 3, 2012 9:05 PM

    ashish vikas wrote:
    > Execution Plan
    > Explain from v$sql_plan not possible ->  Explain from PLAN_TABLE is displayed !
    > No values in v$sql_plan for Address: 0000000166710240 Hash_value:  3891403872 Child_number:  0 Sql_id:
    >
    >  SELECT STATEMENT ( Estimated Costs = 905.739 , Estimated #Rows = 110.190.667 )
    >
    >         1 TABLE ACCESS FULL ZABSA
    >           ( Estim. Costs = 905.739 , Estim. #Rows = 110.190.667 )
    >           Estim. CPU-Costs = 152.614.535.266 Estim. IO-Costs = 899.784
    >           Filter Predicates
    >
    > NONUNIQUE  Index   ZABSA~Z01
    > Column Name                     #Distinct
    > MANDT                                          1
    > ZABCD                                         1
    Hi,
    with this WHERE clause, both columns just one distinct value, the Full Table Scan is indded the best approach, beside
    the point you only need a check to evaluate a value is NOT in the result.
    In this case you should HINT the statement to the new index, because the DB will always assume that this index is non-selective.
    Volker

Maybe you are looking for

  • Customize -java-wsdl-mapping.xml with EJB3 web service

    Using OC4J 10.1.3, I have an EJB that I am exposing as a web service using JSR-181 annotations. Is it possible to customize the generated <ServiceName>-java-wsdl-mapping.xml file? I tried putting my own version in META-INF/ of my ejb jar, but it didn

  • Adding a Parameter

    Hi All I have two fields WORK CODE & WORK DESCRIPTION, i have to generate a new report where in i need to join these two fileds as one and nameit as WORKTYPE, and i am successful in doing so,Now i need to add this new field WORKTYPE as a parameter, w

  • Custom Objects List Using ABAP Program

    Hi Experts, We have  a requirement to collect all the custom objects(reports,smartforms,ddic objects etc)developed in ECC. We need list basing on condition of 'last changed by' . So for few objects we have 'last changed by' field and we are able to g

  • Line size and line count

    Hi all, May i know about line size and line count impact on reports ? i mean depending on line sizes values i.e 200 etc hw it will effect report either in output display  or length ? and also ablout line count too. Thanks in advance.

  • Getting rid of highlight around the border when a TableView gains focus

    Hello, Is there a way remove the highlight around the border of a TableView when it gains focus? Thanks.