Sql is not using index

SELECT DISTINCT eval.match_student_name (a.booking_id,
                                         2059980
                                        ) "Student Name",
                NVL (b.student_email, b.email_address) email_address,
                a.booking_id "Student Registration Number",
                b.customer_name "Company Name",
                DECODE (b.pmt_confirmed,
                        'E', 'Exception',
                        'Y', 'Yes',
                        'N', 'No'
                       ) "Confirmed Commitment ",
                '1' "Edit", a.title "Class Id",
                b.exception_comments "Exception Comments",
                NVL (b.opn_member, 'N') "OPN_Member",
                NVL (b.opn_partner_name, '-') "OPN Company Name",
                a.booking_id "View Attendance",
                DECODE (eval.check_bookingid_push_gsi (a.booking_id),
                        1, apex_item.checkbox (1, a.booking_id, 'Checked'),
                        apex_item.checkbox (1, a.booking_id, 'Disabled')
                       ) "Select",
                DECODE
                   (eval.check_bookingid_push_gsi (a.booking_id),
                    1, 'Ready TO push TO GSI',
                    2, 'In Progress',
                    3, 'Complete',
                    'MANUAL'
                   ) "Booking ID Status"
           FROM ( select * from eval.eattend_student_attendance where title = 2059980 ) a,
                ( select * from eval.eattend_student_info where verified_by IS NOT NULL ) b
          WHERE
            --AND b.verified_by IS NOT NULL
        a.title = b.title
       AND a.booking_id = b.booking_id
       ORDER BY a.booking_idExecution Plan
Plan hash value: 3921177175
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 11 | 1870 | 353 (3)| 00:00:05 |
| 1 | SORT ORDER BY | | 11 | 1870 | 353 (3)| 00:00:05 |
| 2 | HASH UNIQUE | | 11 | 1870 | 352 (3)| 00:00:05 |
| 3 | NESTED LOOPS | | | | | |
| 4 | NESTED LOOPS | | 11 | 1870 | 351 (2)| 00:00:05 |
|* 5 | TABLE ACCESS FULL | EATTEND_STUDENT_ATTENDANCE | 11 | 176 | 318 (3)|
|* 6 | INDEX RANGE SCAN | PERF_EATTEND_STUDENT_INFO_N98 | 1 | | 2 (0)| 0
|* 7 | TABLE ACCESS BY INDEX ROWID| EATTEND_STUDENT_INFO | 1 | 154 | 3 (0)| 0
pls see the table full access of EATTEND_STUDENT_ATTENDANCE , i have a index in that table for a column being used in sql. why index not used ???
thanks
Raj

Because Optimizer thinks that the query will take longer when using an index.
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:736825544526
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:9422487749968
Please use:
explain plan for [your query];and then
select * from table(dbms_xplan.display);when you want an execution plan.

Similar Messages

  • Querys not using indexes

    hi all.
    I want to know wich querys in not using indexes. this is posible??
    My db version is 10.2
    Thanks.

    gomcar wrote:
    hi all.
    I want to know wich querys in not using indexes. this is posible??
    My db version is 10.2
    Thanks.Here is something that I just put together as a possible solution. You probably do not want to execute this SQL statement frequently as it might cause a latching problem (note, not thoroughly tested):
    SELECT /*+ ORDERED */
      SP.SQL_ID,
      SP.HASH_VALUE,
      SP.CHILD_NUMBER,
      S.SQL_TEXT
    FROM
      (SELECT
        SP.SQL_ID,
        SP.HASH_VALUE,
        SP.CHILD_NUMBER,
        SUM(DECODE(INSTR(SP.OBJECT_TYPE,'INDEX'),0,0,1)) COUNTER
      FROM
        V$SQL_PLAN_STATISTICS_ALL SP
      WHERE
        SP.OBJECT_TYPE IS NOT NULL
      GROUP BY
        SP.SQL_ID,
        SP.HASH_VALUE,
        SP.CHILD_NUMBER
      HAVING
        SUM(DECODE(INSTR(SP.OBJECT_TYPE,'INDEX'),0,0,1))=0) SP,
      V$SQL S
    WHERE
      SP.SQL_ID=S.SQL_ID
      AND SP.HASH_VALUE=S.HASH_VALUE
      AND SP.CHILD_NUMBER=S.CHILD_NUMBER
    ORDER BY
      S.SQL_TEXT;Explanation of the above:
    The above looks at the stored execution plans for the queries currently in the shared pool, throwing out any line in the plan where no object is specified. If the OBJECT_TYPE column is found to not contain the word INDEX, a 0 is returned, otherwise a 1 is returned for that line in the plan. The sum of this generated column is calculated for each plan, and those plans having the sum of the generated column equal to 0 are returned. This inline view then drives into the V$SQL view to retrieve the matching SQL statements. An ordered hint is used to make certain that Oracle drives from the inline view into V$SQL.
    Charles Hooper
    IT Manager/Oracle DBA
    K&M Machine-Fabricating, Inc.

  • Query can not use index

    1,i found a sql :select userid,repute from user_attribute where
    repute>3000 order by repute desc
    cost heavily;
    SELECT STATEMENT Cost = 637
    SORT ORDER BY
    TABLE ACCESS FULL USER_ATTRIBUTE
    2,i use: select index_name from user_indexes where table_name
    = 'USER_ATTRIBUTE'
    INDEX_NAME
    IDX_USER_ATTRIBUTE_FACE
    IDX_USER_ATTRIBUTE_POWER
    IDX_USER_ATTRIBUTE_REPUTE
    IDX_USER_ATTRIBUTE_USERID
    so column repute has indexed
    3, i use CBO with analysize shema compute
    optimizer_index_caching integer 99
    optimizer_index_cost_adj integer 5
    4,i use: select /*index(IDX_USER_ATTRIBUTE_REPUTE)*/
    userid,repute from user_attribute where repute>3000 order by
    repute desc
    i got same explain plan as old
    5,why it can not use index to query,thanks.

    I think your optimizer hint syntax is wrong. you need a "+"
    sign to indicate that the comment block is an optimizer hint,
    and the table name is not optional in the index hints
    select /*+ index(user_attribute
    IDX_USER_ATTRIBUTE_REPUTE)*/
    userid,repute from user_attribute where repute>3000 order
    by
    repute desc
    also, try ...
    select /*+ index_desc(user_attribute
    IDX_USER_ATTRIBUTE_REPUTE)*/
    userid,repute from user_attribute where repute>3000
    This should order the result for you.

  • Not Using Index on File Server When Accessing User Files Directly on Server

    It appears to me that on a server with an indexed network share (Desktop Experience and Search Indexing roles/features installed), if you access the share directly on the server using its drive path, you can search the folders using the index, which
    is much faster and supports finding words inside of the files in seconds). However, if you access the same shared folder via its network path from the server itself, the server ignores the index. I have this experience/problem across all shared folders on
    the Windows 2012 R2 Server. Details and my most specific goal follows.
    In addition to a laptop, I frequently work directly on a Windows Server 2012 R2 computer. We have Redirected Folders set up on DFS (for failover redundancy) so that my Documents folder is in:
    \\network\redirections\user\documents. This all works fine on Windows 7 and 8 client computers connected to the network via Offline Files.
    The problem is on the server itself. The server has Desktop Experience enabled and Windows Search is installed. If I navigate manually through the DFS root folder to my documents folder, I can search and it properly uses the index. This proves the location
    is properly indexed. However, if I access the folders through the official "Documents" folder from the Folder Redirection (a network share pointing to the same server computer I'm working on), it performs an un-indexed search (slow and ignores file
    contents, but does find files eventually if the search term is in their filename). Is there a way to force the server to use the indexed search on the Redirected Folders (my Documents folder in particular) when working on that server when logged in locally
    on that server?
    I suspect a workaround would be to go into the Registry and manually change the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders to point to the local DFS folder instead of the network share name, but at least one problem
    with this is then if I save files with links to other files (e.g., a linked Excel table in a PowerPoint, a mail merge to Access database in Word, etc.) on the server computer, those links will point to d:\DFSroot\... (a physical drive on the computer) instead
    of \\network\redirections\user\... (a universally accessible network path) and so none of the other computers will be able to find the linked files, defeating one of the
    major benefits of using Redirected Folders.
    I can't believe that I need to choose between indexed searching and proper path names in saved files. Surely there is a way to use an indexed search on the server itself?
    If you need any more info to help me troubleshoot, please let me know.
    Thanks for any help,
    Colin

    Hi Colin,
    It seems that we can not use indexed search on DFS shares. Windows Search works well when users directly access the server. That is, the server is not made available through Distributed File System (DFS).
    For more detailed information, you could refer to the links below:
    Windows Search Service, Clustered File Services, DFS, Win7 Libraries
    https://social.technet.microsoft.com/Forums/windowsserver/en-US/31ac4c16-948b-4ca4-b18f-3a339cdfd5b9/windows-search-service-clustered-file-services-dfs-win7-libraries?forum=winserverfiles
    Windows Browse and Organize Features
    https://technet.microsoft.com/en-us/library/dd744693(WS.10).aspx
    Best Regards,
    Mandy 
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • Queries not using indexes

    We installed and configured a new environment of OBIEE and are trying to run a simple query in our data warehouse. This simple query takes only 7 seconds to complete in our previous data warehouse using TOAD but is taking 8+ minutes to complete in our new environment also using TOAD.
    Looking at the explain plans, the query in the new environment is not using indexes. Does anyone have an idea why it is not using the indexes? We checked and all of the indexes have been created and still exist. We also ran Analyze again on the two tables used n the query but the query still did not use the indexes.
    Please let me know if anyone has ideas ASAP since we are baffled.

    - Are the object statistics identical? The ANALYZE statement has been depricated for a while, particularly for data warehouse environments where there may be partitioning. Were you not using the DBMS_STATS package to gather statistics in the previous environment? Were statistics computed on the indexes?
    - Can you post the two query plans (formatted via DBMS_XPLAN and including the filter conditions)? It is not immediately obvious to me what index(es) might be useful here unless one of the two conditions is particularly selective which doesn't seem terribly likely based on just the table names involved.
    - When you do post the query plans, please use the \[code\] and \[code\] tags to preserve the white space so that the output is readable.
    Justin

  • SQL Query not using Composite Index

    Hi,
    Please look at the below query:
    SELECT pde.participant_uid
    ,pde.award_code
    ,pde.award_type
    ,SUM(decode(pde.distribution_type
    ,'FORFEITURE'
    ,pde.forfeited_quantity *
    pde.sold_price * cc.rate
    ,pde.distributed_quantity *
    pde.sold_price * cc.rate)) AS gross_Amt_pref_Curr
    FROM part_distribution_exec pde
    ,currency_conversion cc
    ,currency off_curr
    WHERE pde.participant_uid = 4105
    AND off_curr.currency_iso_code =
    pde.offering_currency_iso_code
    AND cc.from_currency_uid = off_curr.currency_uid
    AND cc.to_currency_uid = 1
    AND cc.latest_flag = 'Y'
    GROUP BY pde.participant_uid
    ,pde.award_code
    ,pde.award_type
    In oracle 9i, i"ve executed this above query, it takes 6 seconds and the cost is 616, this is due to non usage of the composite index, Currency_conversion_idx(From_currency_uid, To_currency_uid, Latest_flag). I wonder why this index is not used while executing the above query. So, I've dropped the index and recreated it. Now, the query is using this index. After inserting many rows or say in 1 days time, if the same query is executed, again the query is not using the index. So everyday, the index should be dropped and recreated.
    I don't want this drop and recreation of index daily, I need a permanent solution for this.
    Can anyone tell me, Why this index goes stale after a period of time???? Please take some time and Solve this issue.
    -Sankar

    Hi David,
    This is Sankar here. Thankyou for your reply.
    I've got the plan table output for this problematic query, please go thro' it and help me out why the index CURRENCY_CONVERSION_IDX is used now and why it's not using while executing the query after a day or inserting some records...
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes | Cost |
    | 0 | SELECT STATEMENT | | 26 | 15678 | 147 |
    | 1 | TABLE ACCESS BY INDEX ROWID | PART_AWARD_PAYOUT_SCHEDULE | 1 | 89 | 2 |
    |* 2 | INDEX UNIQUE SCAN | PART_AWARD_PAYOUT_SCHEDULE_PK1 | 61097 | | 1 |
    | 3 | SORT AGGREGATE | | 1 | 67 | |
    |* 4 | FILTER | | | | |
    |* 5 | INDEX RANGE SCAN | PART_AWARD_PAYOUT_SCHEDULE_PK1 | 1 | 67 | 2 |
    | 6 | SORT AGGREGATE | | 1 | 94 | |
    |* 7 | FILTER | | | | |
    |* 8 | TABLE ACCESS BY INDEX ROWID | PART_AWARD_PAYOUT_SCHEDULE | 1 | 94 | 3 |
    |* 9 | INDEX RANGE SCAN | PART_AWARD_PAYOUT_SCHEDULE_PK1 | 1 | | 2 |
    |* 10 | FILTER | | | | |
    |* 11 | HASH JOIN | | 26 | 15678 | 95 |
    |* 12 | HASH JOIN OUTER | | 26 | 11596 | 91 |
    |* 13 | HASH JOIN | | 26 | 10218 | 86 |
    | 14 | VIEW | | 1 | 82 | 4 |
    | 15 | SORT GROUP BY | | 1 | 116 | 4 |
    |* 16 | TABLE ACCESS BY INDEX ROWID | PART_AWARD_LEDGER | 1 | 116 | 2 |
    |* 17 | INDEX RANGE SCAN | PARTICIPANT_UID_IDX | 1 | | 1 |
    |* 18 | HASH JOIN OUTER | | 26 | 8086 | 82 |
    |* 19 | HASH JOIN | | 26 | 6006 | 71 |
    | 20 | NESTED LOOPS | | 36 | 5904 | 66 |
    | 21 | NESTED LOOPS | | 1 | 115 | 65 |
    | 22 | TABLE ACCESS BY INDEX ROWID | CURRENCY_CONVERSION | 18 | 756 | 2 |
    |* 23 | INDEX RANGE SCAN | KLS_IDX_CURRENCY_CONV | 3 | | 1 |
    | 24 | VIEW | | 1 | 73 | 4 |
    | 25 | SORT GROUP BY | | 1 | 71 | 4 |
    | 26 | TABLE ACCESS BY INDEX ROWID| PART_AWARD_VALUE | 1 | 71 | 2 |
    |* 27 | INDEX RANGE SCAN | PAV_PARTICIPANT_UID_IDX | 1 | | 1 |
    | 28 | TABLE ACCESS BY INDEX ROWID | PARTICIPANT_AWARD | 199 | 9751 | 1 |
    |* 29 | INDEX UNIQUE SCAN | PARTICIPANT_AWARD_PK1 | 100 | | |
    |* 30 | INDEX FAST FULL SCAN | PARTICIPANT_AWARD_TYPE_PK1 | 147 | 9849 | 4 |
    | 31 | VIEW | | 1 | 80 | 10 |
    | 32 | SORT GROUP BY | | 1 | 198 | 10 |
    |* 33 | TABLE ACCESS BY INDEX ROWID | CURRENCY_CONVERSION | 1 | 42 | 2 |
    | 34 | NESTED LOOPS | | 1 | 198 | 8 |
    | 35 | NESTED LOOPS | | 2 | 312 | 4 |
    | 36 | TABLE ACCESS BY INDEX ROWID| PART_DISTRIBUTION_EXEC | 2 | 276 | 2 |
    |* 37 | INDEX RANGE SCAN | IND_PARTICIPANT_UID | 1 | | 1 |
    | 38 | TABLE ACCESS BY INDEX ROWID| CURRENCY | 1 | 18 | 1 |
    |* 39 | INDEX UNIQUE SCAN | CURRENCY_AK | 1 | | |
    |* 40 | INDEX RANGE SCAN | CURRENCY_CONVERSION_AK | 2 | | 1 |
    | 41 | VIEW | | 1 | 53 | 4 |
    | 42 | SORT GROUP BY | | 1 | 62 | 4 |
    |* 43 | TABLE ACCESS BY INDEX ROWID | PART_AWARD_VESTING | 1 | 62 | 2 |
    |* 44 | INDEX RANGE SCAN | PAVES_PARTICIPANT_UID_IDX | 1 | | 1 |
    | 45 | TABLE ACCESS FULL | AWARD | 1062 | 162K| 3 |
    | 46 | TABLE ACCESS BY INDEX ROWID | CURRENCY | 1 | 18 | 2 |
    |* 47 | INDEX UNIQUE SCAN | CURRENCY_AK | 102 | | 1 |
    Predicate Information (identified by operation id):
    2 - access("PAPS"."AWARD_CODE"=:B1 AND "PAPS"."PARTICIPANT_UID"=4105 AND "PAPS"."AWARD_TYPE"=:B2
    "PAPS"."INSTALLMENT_NUM"=1)
    4 - filter(4105=:B1)
    5 - access("PAPS"."AWARD_CODE"=:B1 AND "PAPS"."PARTICIPANT_UID"=4105 AND "PAPS"."AWARD_TYPE"=:B2)
    7 - filter(4105=:B1)
    8 - filter("PAPS"."STATUS"='OPEN')
    9 - access("PAPS"."AWARD_CODE"=:B1 AND "PAPS"."PARTICIPANT_UID"=4105 AND "PAPS"."AWARD_TYPE"=:B2)
    10 - filter("CC_A_P_CURR"."FROM_CURRENCY_UID"= (SELECT /*+ */ "CURRENCY"."CURRENCY_UID" FROM
    "EWAPDBO"."CURRENCY" "CURRENCY" WHERE "CURRENCY"."CURRENCY_ISO_CODE"=:B1))
    11 - access("SYS_ALIAS_7"."AWARD_CODE"="A"."AWARD_CODE")
    12 - access("SYS_ALIAS_7"."AWARD_CODE"="PVS"."AWARD_CODE"(+))
    13 - access("SYS_ALIAS_8"."AWARD_CODE"="PALS"."AWARD_CODE" AND
    "SYS_ALIAS_8"."AWARD_TYPE"="PALS"."AWARD_TYPE")
    16 - filter(TRUNC("PAL1"."LEDGER_ENTRY_DATE")<=TRUNC(SYSDATE@!) AND "PAL1"."ALLOC_TYPE"='IPU')
    17 - access("PAL1"."PARTICIPANT_UID"=4105)
    filter("PAL1"."PARTICIPANT_UID"=4105)
    18 - access("SYS_ALIAS_8"."AWARD_CODE"="PDES"."AWARD_CODE"(+) AND
    "SYS_ALIAS_8"."AWARD_TYPE"="PDES"."AWARD_TYPE"(+))
    19 - access("SYS_ALIAS_7"."AWARD_CODE"="SYS_ALIAS_8"."AWARD_CODE")
    23 - access("CC_A_P_CURR"."TO_CURRENCY_UID"=1 AND "CC_A_P_CURR"."LATEST_FLAG"='Y')
    27 - access("PAV"."PARTICIPANT_UID"=4105)
    filter("PAV"."PARTICIPANT_UID"=4105)
    29 - access("SYS_ALIAS_7"."AWARD_CODE"="SYS_ALIAS_9"."AWARD_CODE" AND
    "SYS_ALIAS_7"."PARTICIPANT_UID"=4105)
    30 - filter("SYS_ALIAS_8"."PARTICIPANT_UID"=4105)
    33 - filter("CC"."LATEST_FLAG"='Y')
    37 - access("PDE"."PARTICIPANT_UID"=4105)
    filter("PDE"."PARTICIPANT_UID"=4105)
    39 - access("OFF_CURR"."CURRENCY_ISO_CODE"="PDE"."OFFERING_CURRENCY_ISO_CODE")
    40 - access("CC"."FROM_CURRENCY_UID"="OFF_CURR"."CURRENCY_UID" AND "CC"."TO_CURRENCY_UID"=1)
    43 - filter("PV"."VESTING_DATE"<=SYSDATE@!)
    44 - access("PV"."PARTICIPANT_UID"=4105)
    filter("PV"."PARTICIPANT_UID"=4105)
    47 - access("CURRENCY"."CURRENCY_ISO_CODE"=:B1)
    Note: cpu costing is off
    93 rows selected.
    Please help me out...
    -Sankar

  • Query not using indexes

    select *
              from hrm_career x
              WHERE x.begin_date = ( SELECT MAX(begin_date)
                             FROM hrm_career y
                             WHERE y.employee_id = x.employee_id AND
                                  begin_date <= SYSDATE AND
                                  primary_job = 'Y') AND
                   x.primary_job = 'Y'
    I have the above query which is not using the index created on the BEGIN_DT column
    I tried to force using still not using
    but when i apply a value say
    select *
              from hrm_career x
              WHERE x.begin_date ='10-20-2007'
    It is using index and resulting in very fast response
    Can some throw some ideas on it...
    Where should i look into here ..

    SQL> set autotrace traceonly
    SQL> select *
    2 from hrm_career x
    3 WHERE x.begin_date = ( SELECT MAX(begin_date)
    4 FROM hrm_career y
    5 WHERE y.employee_id = x.employee_id AND
    6 begin_date <= SYSDATE AND
    7 primary_job = 'Y') AND
    8 x.primary_job = 'Y';
    13454 rows selected.
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=1417 Card=152 Bytes=
    35568)
    1 0 FILTER
    2 1 SORT (GROUP BY) (Cost=1417 Card=152 Bytes=35568)
    3 2 HASH JOIN (Cost=254 Card=47127 Bytes=11027718)
    4 3 INDEX (FAST FULL SCAN) OF 'HRM_CAREER_PK' (UNIQUE) (
    Cost=12 Card=25026 Bytes=500520)
    5 3 TABLE ACCESS (FULL) OF 'HRM_CAREER' (Cost=81 Card=25
    335 Bytes=5421690)
    Statistics
    3671 recursive calls
    9 db block gets
    1758 consistent gets
    2130 physical reads
    0 redo size
    2217762 bytes sent via SQL*Net to client
    10359 bytes received via SQL*Net from client
    898 SQL*Net roundtrips to/from client
    128 sorts (memory)
    1 sorts (disk)
    13454 rows processed
    TKPROF
    TKPROF: Release 9.2.0.6.0 - Production on Wed Dec 12 18:40:56 2007
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Trace file: qnhg_ora_500.trc
    Sort options: default
    count = number of times OCI procedure was executed
    cpu = cpu time in seconds executing
    elapsed = elapsed time in seconds executing
    disk = number of physical reads of buffers from disk
    query = number of buffers gotten for consistent read
    current = number of buffers gotten in current mode (usually for update)
    rows = number of rows processed by the fetch or execute call
    ALTER SESSION SET EVENTS '10046 trace name context forever, level 8'
    call count cpu elapsed disk query current rows
    Parse 0 0.00 0.00 0 0 0 0
    Execute 1 0.00 0.00 0 0 0 0
    Fetch 0 0.00 0.00 0 0 0 0
    total 1 0.00 0.00 0 0 0 0
    Misses in library cache during parse: 0
    Misses in library cache during execute: 1
    Optimizer goal: CHOOSE
    Parsing user id: 30 (ADMIN)
    Elapsed times include waiting on following events:
    Event waited on Times Max. Wait Total Waited
    ---------------------------------------- Waited ---------- ------------
    SQL*Net message to client 1 0.00 0.00
    SQL*Net message from client 1 34.45 34.45
    select condition
    from
    cdef$ where rowid=:1
    call count cpu elapsed disk query current rows
    Parse 4 0.00 0.00 0 0 0 0
    Execute 4 0.00 0.00 0 0 0 0
    Fetch 4 0.00 0.00 0 8 0 4
    total 12 0.00 0.00 0 8 0 4
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: SYS (recursive depth: 1)
    Rows Row Source Operation
    1 TABLE ACCESS BY USER ROWID CDEF$
    select *
    from hrm_career x
    WHERE x.begin_date = ( SELECT MAX(begin_date)
    FROM hrm_career y
    WHERE y.employee_id = x.employee_id AND
    begin_date <= SYSDATE AND
    primary_job = 'Y') AND
    x.primary_job = 'Y'
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.07 0 0 0 0
    Execute 1 0.00 0.00 0 0 0 0
    Fetch 898 0.00 2.39 2038 946 9 13454
    total 900 0.00 2.46 2038 946 9 13454
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 30 (ADMIN)
    Rows Row Source Operation
    13454 FILTER
    25335 SORT GROUP BY
    67496 HASH JOIN
    25333 INDEX FAST FULL SCAN HRM_CAREER_PK (object id 25292)
    25336 TABLE ACCESS FULL HRM_CAREER
    Rows Execution Plan
    0 SELECT STATEMENT GOAL: CHOOSE
    13454 FILTER
    25335 SORT (GROUP BY)
    67496 HASH JOIN
    25333 INDEX GOAL: ANALYZED (FAST FULL SCAN) OF 'HRM_CAREER_PK'
    (UNIQUE)
    25336 TABLE ACCESS GOAL: ANALYZED (FULL) OF 'HRM_CAREER'
    Elapsed times include waiting on following events:
    Event waited on Times Max. Wait Total Waited
    ---------------------------------------- Waited ---------- ------------
    SQL*Net message to client 898 0.00 0.00
    SQL*Net more data to client 877 0.00 0.05
    db file sequential read 1 0.01 0.01
    db file scattered read 60 0.00 0.14
    direct path write 9 0.00 0.00
    direct path read 125 0.05 0.13
    SQL*Net message from client 898 0.02 1.47
    DELETE FROM PLAN_TABLE
    WHERE
    STATEMENT_ID=:1
    call count cpu elapsed disk query current rows
    Parse 2 0.00 0.00 0 0 0 0
    Execute 2 0.00 0.00 0 6 6 6
    Fetch 0 0.00 0.00 0 0 0 0
    total 4 0.00 0.00 0 6 6 6
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 30 (ADMIN)
    Rows Row Source Operation
    0 DELETE
    0 TABLE ACCESS FULL PLAN_TABLE
    Rows Execution Plan
    0 DELETE STATEMENT GOAL: CHOOSE
    0 DELETE OF 'PLAN_TABLE'
    0 TABLE ACCESS (FULL) OF 'PLAN_TABLE'
    Elapsed times include waiting on following events:
    Event waited on Times Max. Wait Total Waited
    ---------------------------------------- Waited ---------- ------------
    SQL*Net message to client 2 0.00 0.00
    SQL*Net message from client 2 14.77 14.79
    select o.owner#,o.name,o.namespace,o.remoteowner,o.linkname,o.subname,
    o.dataobj#,o.flags
    from
    obj$ o where o.obj#=:1
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 0.00 0.00 0 0 0 0
    Fetch 1 0.00 0.00 0 3 0 1
    total 3 0.00 0.00 0 3 0 1
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: SYS (recursive depth: 1)
    EXPLAIN PLAN SET STATEMENT_ID='PLUS74964' FOR select *
    from hrm_career x
    WHERE x.begin_date = ( SELECT MAX(begin_date)
    FROM hrm_career y
    WHERE y.employee_id = x.employee_id AND
    begin_date <= SYSDATE AND
    primary_job = 'Y') AND
    x.primary_job = 'Y'
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.01 0 4 0 0
    Execute 1 0.00 0.00 0 0 0 0
    Fetch 0 0.00 0.00 0 0 0 0
    total 2 0.00 0.01 0 4 0 0
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 30 (ADMIN)
    Elapsed times include waiting on following events:
    Event waited on Times Max. Wait Total Waited
    ---------------------------------------- Waited ---------- ------------
    SQL*Net message to client 1 0.00 0.00
    SQL*Net message from client 1 0.00 0.00
    insert into plan_table (statement_id, timestamp, operation, options,
    object_node, object_owner, object_name, object_instance, object_type,
    search_columns, id, parent_id, position, other,optimizer, cost, cardinality,
    bytes, other_tag, partition_start, partition_stop, partition_id,
    distribution, cpu_cost, io_cost, temp_space, access_predicates,
    filter_predicates )
    values
    (:1,SYSDATE,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,:15,:16,:17,:18,:19,
    :20,:21,:22,:23,:24,:25,:26,:27)
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 6 0.00 0.00 0 3 6 6
    Fetch 0 0.00 0.00 0 0 0 0
    total 7 0.00 0.00 0 3 6 6
    Misses in library cache during parse: 1
    Misses in library cache during execute: 2
    Optimizer goal: CHOOSE
    Parsing user id: 30 (ADMIN) (recursive depth: 1)
    Rows Execution Plan
    0 INSERT STATEMENT GOAL: CHOOSE
    select o.name, u.name
    from
    sys.obj$ o, sys.user$ u where obj# = :1 and owner# = user#
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 0 0.00 0.00 0 0 0 0
    Fetch 0 0.00 0.00 0 0 0 0
    total 1 0.00 0.00 0 0 0 0
    Misses in library cache during parse: 1
    Parsing user id: SYS (recursive depth: 1)
    SELECT ID ID_PLUS_EXP,PARENT_ID PARENT_ID_PLUS_EXP,LPAD(' ',2*(LEVEL-1))
    ||OPERATION||DECODE(OTHER_TAG,NULL,'','*')||DECODE(OPTIONS,NULL,'','
    ('||OPTIONS||')')||DECODE(OBJECT_NAME,NULL,'',' OF '''||OBJECT_NAME||'''')
    ||DECODE(OBJECT_TYPE,NULL,'',' ('||OBJECT_TYPE||')')||DECODE(ID,0,
    DECODE(OPTIMIZER,NULL,'',' Optimizer='||OPTIMIZER))||DECODE(COST,NULL,'','
    (Cost='||COST||DECODE(CARDINALITY,NULL,'',' Card='||CARDINALITY)
    ||DECODE(BYTES,NULL,'',' Bytes='||BYTES)||')') PLAN_PLUS_EXP,OBJECT_NODE
    OBJECT_NODE_PLUS_EXP
    FROM
    PLAN_TABLE START WITH ID=0 AND STATEMENT_ID=:1 CONNECT BY PRIOR ID=PARENT_ID
    AND STATEMENT_ID=:1 ORDER BY ID,POSITION
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 0.00 0.00 0 0 0 0
    Fetch 2 0.00 0.00 0 22 0 6
    total 4 0.00 0.00 0 22 0 6
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 30 (ADMIN)
    Rows Row Source Operation
    6 SORT ORDER BY
    6 CONNECT BY WITH FILTERING
    1 NESTED LOOPS
    1 TABLE ACCESS FULL PLAN_TABLE
    1 TABLE ACCESS BY USER ROWID PLAN_TABLE
    5 NESTED LOOPS
    6 BUFFER SORT
    6 CONNECT BY PUMP
    5 TABLE ACCESS FULL PLAN_TABLE
    Rows Execution Plan
    0 SELECT STATEMENT GOAL: CHOOSE
    6 SORT (ORDER BY)
    6 CONNECT BY (WITH FILTERING)
    1 NESTED LOOPS
    1 TABLE ACCESS (FULL) OF 'PLAN_TABLE'
    1 TABLE ACCESS (BY USER ROWID) OF 'PLAN_TABLE'
    5 NESTED LOOPS
    6 BUFFER (SORT)
    6 CONNECT BY PUMP
    5 TABLE ACCESS (FULL) OF 'PLAN_TABLE'
    Elapsed times include waiting on following events:
    Event waited on Times Max. Wait Total Waited
    ---------------------------------------- Waited ---------- ------------
    SQL*Net message to client 2 0.00 0.00
    SQL*Net message from client 2 0.09 0.09
    SELECT ID ID_PLUS_EXP,OTHER_TAG OTHER_TAG_PLUS_EXP,OTHER OTHER_PLUS_EXP
    FROM
    PLAN_TABLE WHERE STATEMENT_ID=:1 AND OTHER_TAG IS NOT NULL ORDER BY ID
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 0.00 0.00 0 0 0 0
    Fetch 1 0.00 0.00 0 3 0 0
    total 3 0.00 0.00 0 3 0 0
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 30 (ADMIN)
    Rows Row Source Operation
    0 SORT ORDER BY
    0 TABLE ACCESS FULL PLAN_TABLE
    Rows Execution Plan
    0 SELECT STATEMENT GOAL: CHOOSE
    0 SORT (ORDER BY)
    0 TABLE ACCESS (FULL) OF 'PLAN_TABLE'
    Elapsed times include waiting on following events:
    Event waited on Times Max. Wait Total Waited
    ---------------------------------------- Waited ---------- ------------
    SQL*Net message to client 2 0.00 0.00
    SQL*Net message from client 2 0.00 0.00
    ALTER SESSION SET EVENTS '10046 trace name context off'
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 0.00 0.00 0 0 0 0
    Fetch 0 0.00 0.00 0 0 0 0
    total 2 0.00 0.00 0 0 0 0
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 30 (ADMIN)
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call count cpu elapsed disk query current rows
    Parse 7 0.00 0.09 0 4 0 0
    Execute 8 0.00 0.00 0 6 6 6
    Fetch 901 0.00 2.39 2038 971 9 13460
    total 916 0.00 2.49 2038 981 15 13466
    Misses in library cache during parse: 6
    Misses in library cache during execute: 1
    Elapsed times include waiting on following events:
    Event waited on Times Max. Wait Total Waited
    ---------------------------------------- Waited ---------- ------------
    SQL*Net message to client 906 0.00 0.00
    SQL*Net message from client 906 34.45 50.82
    SQL*Net more data to client 877 0.00 0.05
    db file sequential read 1 0.01 0.01
    db file scattered read 60 0.00 0.14
    direct path write 9 0.00 0.00
    direct path read 125 0.05 0.13
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    call count cpu elapsed disk query current rows
    Parse 7 0.00 0.00 0 0 0 0
    Execute 11 0.00 0.00 0 3 6 6
    Fetch 5 0.00 0.00 0 11 0 5
    total 23 0.00 0.00 0 14 6 11
    Misses in library cache during parse: 4
    Misses in library cache during execute: 2
    9 user SQL statements in session.
    6 internal SQL statements in session.
    15 SQL statements in session.
    5 statements EXPLAINed in this session.
    Trace file: qnhg_ora_500.trc
    Trace file compatibility: 9.02.00
    Sort options: default
    3 sessions in tracefile.
    12 user SQL statements in trace file.
    8 internal SQL statements in trace file.
    15 SQL statements in trace file.
    11 unique SQL statements in trace file.
    5 SQL statements EXPLAINed using schema:
    ADMIN.prof$plan_table
    Default table was used.
    Table was created.
    Table was dropped.
    3945 lines in trace file.
    Message was edited by:
    Maran Viswarayar

  • Optimizer not using index even after giving the hint

    Hi All,
    I am wondering why Optimixzer is not using the index in the below query
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    SQL> select column_expression
      2  from ALL_IND_EXPRESSIONS
      3  where table_name like 'GTXN_DTL_V1'
      4  and index_name = 'IDX_TXN11_V1';
    COLUMN_EXPRESSION
    TO_DATE("BOOKING_DATE",'YYYYMMDD')
    SQL> select num_rows from all_tables
      2  where table_name like 'GTXN_DTL_V1';
      NUM_ROWS
      29020867
    SQL>  explain plan for select * from gtxn_dtl_v1 where to_date(booking_date,'yyyymmdd') = to_date('030109','DDMMRR');
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3140624094
    | Id  | Operation         | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |             | 55489 |    15M|   215K  (4)| 00:43:08 |
    |*  1 |  TABLE ACCESS FULL| GTXN_DTL_V1 | 55489 |    15M|   215K  (4)| 00:43:08 |
    Predicate Information (identified by operation id):
       1 - filter(TO_DATE("BOOKING_DATE",'yyyymmdd')=TO_DATE('030109','DDMMRR
    14 rows selected.
    --Giving Hint..
    SQL> explain plan for select /*+ index(gtxn_dtl_v1 IDX_TXN11_V1) */ *
      2  from gtxn_dtl_v1
      3  where to_date(booking_date,'yyyymmdd') = to_date('030109','DDMMRR')
      4  /
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3140624094
    | Id  | Operation         | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |             | 55489 |    15M|   215K  (4)| 00:43:08 |
    |*  1 |  TABLE ACCESS FULL| GTXN_DTL_V1 | 55489 |    15M|   215K  (4)| 00:43:08 |
    Predicate Information (identified by operation id):
       1 - filter(TO_DATE("BOOKING_DATE",'yyyymmdd')=TO_DATE('030109','DDMMRR
    14 rows selected.Please suggest.
    Thanks in advance,
    Jeneesh

    porzer wrote:
    Hi!
    Why are you using the to_date ont the booking_date column? Is it a varchar2 column, what type is it.
    Because if it's a varchar2 column you could simply use
    select * from gtxn_dtl_v1 where booking_date = '20090103';
    So you wouldn't even need a function based index.
    On the other hand if it's a date you shouldn't do a to_date as well.
    Best regards,
    PPThat is not the original qury used in production. I am investigating on the prformance of the below query.
    select  txn.account_number,to_number(txn.amount_lcy) txn_amt,to_date(booking_date,'yyyymmdd') TXN_DATE,
          sal.latest_sal,sal.sal_date,customer_name,employer_name,
           decode(COMMUNICATION_TYPE_1,'MOBILE',COMMUNICATION_NO_1,decode(COMMUNICATION_TYPE_2,'MOBILE',COMMUNICATION_NO_2)) mob,
           txn.CURRENCY, CHEQUE_NUMBER,trans_dets,trans_reference,target,teller_id,acc.category,acc.inactive_marker,acc.posting_restrict,cus.sector,cus.industry
    from coreadmin.Gtxn_dtl_v1 txn,
                   (select account_number,round(to_number(nvl(amount_lcy,0)),2) latest_sal,TXN_DATE sal_date,rr
                    from
                      (select to_date(booking_date,'yyyymmdd') TXN_DATE,batch_id,account_number,amount_lcy
                             ,row_number() over (partition by account_number order by to_date(booking_date,'yyyymmdd') desc NULLS LAST,batch_id desc nulls last) rr,
                             CURRENCY, CHEQUE_NUMBER,trans_dets,trans_reference
                        from coreadmin.Gtxn_dtl_v1
                        where transaction_code = '204'
                    and to_number(amount_lcy) > 0)
                        where rr = 1
                     ) sal,customers_live cus,accounts_live acc
    where to_date(booking_date,'yyyymmdd') between to_date('030109','DDMMRR') and to_date('030209','DDMMRR')
    and txn.account_number = sal.account_number
    and txn.CUSTOMER_ID = cus.CUSTOMER_number(+)
    and acc.id = sal.account_number
    and target in ('30','31','32')Edited by: jeneesh on Mar 25, 2009 12:38 PM
    Corrected the query.
    The column is of VARCHAR2 type. This is because, the table is loaded, through sqlldr, every day from flat files generated form GLOBUS banking system. Column is kept as VARCHAR2 to minimize the loading issues.

  • Update databse from internal table statement not using index

    Hi Guys,
    We are updating a databse table from a file. The file has a couple of fields which have data different from what the database has (non-primary fields :). We upload the file data into an internal table and then update the database table from internal table. At a time, internal table is supposed to have 10,000 records. I did SQL trace and found that the update statement is not making use of the databse index.
    Should not the update statement here be using the table index (for primary key)?
    Regards,
    Munish

    ... as often there are recommendations in this forum which makes me wonder, how people overestimate their knowledge!!!
    Updates and Deletes do of course use indexes, as can be seen in the SQL Trace (use explain).
    Inserts don't use indexes, because in many databases inserts are just done somewhere, But also with the INSERT, the primary key is the constraint for the uniqueness condition, duplicate keys are not allowed.
    Coming to the original question, what is you actually coding for the update?
    What is the table, which fields are in the internal table and what are the indexes?
    Siegfried

  • "Tables are not using indexes"-Please help

    We have a new database , version
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
    PL/SQL Release 10.2.0.1.0 - Production
    CORE 10.2.0.1.0 Production
    TNS for IBM/AIX RISC System/6000: Version 10.2.0.1.0 - Productio
    NLSRTL Version 10.2.0.1.0 - Production
    We have created Indexes for the tables and analysed the table. Problem is , non of the tables are using indexes. Explain paln for the sql queries are showing full table scan.
    Kindly let me know any parameter I have to change or is there any setttings needed on database level?
    Thanks in advance.
    Regards,
    Chotu

    What is your optimizer mode?
    Another question why you want to use indexes? Use of indexes depends,
    Here is a simple example
    test@>ed
    Wrote file afiedt.buf
      1  explain plan for
      2  select c.cname from mytable c, mytable1 m
      3* where c.cname=m.cname
    test@>/
    Explained.
    test@>SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());
    PLAN_TABLE_OUTPUT
    Plan hash value: 2460944079
    | Id  | Operation         | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |              |     8 |    64 |     1   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS     |              |     8 |    64 |     1   (0)| 00:00:01 |
    |   2 |   INDEX FULL SCAN | C_MYTAB_IDX  |     8 |    32 |     1   (0)| 00:00:01 |
    |*  3 |   INDEX RANGE SCAN| C_MYTAB1_IDX |     1 |     4 |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       3 - access("C"."CNAME"="M"."CNAME")
    15 rows selected.
    test@>explain plan for
      2  select * from mytable;
    Explained.
    test@>SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());
    PLAN_TABLE_OUTPUT
    Plan hash value: 1229213413
    | Id  | Operation         | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |         |     8 |    32 |     3   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| MYTABLE |     8 |    32 |     3   (0)| 00:00:01 |
    8 rows selected.As you see MYTABLE has an index but it not always uses that index it depends on the need.
    sql queries are showing full table scan this is a not a curse. So unless you are having some problem. You should not change queries only because to avoid full table scans, there is no rule that indexes should always be used in every case.
    Adith

  • Simple query but not using index..please help??

    I do have this column indexed. Why my query is not using this index?
    Any help .
    select count(*) from v_dis_sub_har;
    SQL>
      COUNT(*)
       4543289
    1 row selected.
    SQL>
    select vzw_vendor_id , count(*)
    from v_dis_sub_har
    group by vzw_vendor_id
    SQL>   2    3    4 
    VZW_VENDOR_ID   COUNT(*)
           200091     908653
           200013     908659
           200012     908659
           200057     908659
           200031     908659
    5 rows selected.
    SQL> SQL>
    explain plan for
    select
    event_seq
    from v_dis_sub_har b 
    where b.VZW_VENDOR_ID='200013'
    -- and b.status='P' and b.extract_date is null
    SQL>   2    3    4    5    6    7 
    Explained.
    SQL> SQL>
    select plan_table_output from table(dbms_xplan.display)
    SQL> SQL>   2 
    PLAN_TABLE_OUTPUT
    Plan hash value: 2852398983
    | Id  | Operation         | Name          | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |               |   908K|  7986K|  3132  (16)| 00:00:38 |
    |*  1 |  TABLE ACCESS FULL| V_DIS_SUB_HAR |   908K|  7986K|  3132  (16)| 00:00:38 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       1 - filter("B"."VZW_VENDOR_ID"=200013)
    13 rows selected.
    SQL> SQL>

    You are right Justin. Oracle is not stupid as you may want to say some times when things do not happen according to you. I just created a bitmap index on status field and look what appened. Som times it uses bitmap index and some times it does not. And the reason is clear. Row count by status. 'S' status uses bitmap index where 'P' does not.
    Thanks for your help.
    select   status, count(*)
    from v_dis_sub_har
    group  by status
    ;SQL>   2    3    4 
    S   COUNT(*)
    A    5844982
    P    2312759
    S      20178
    3 rows selected.
    SQL>
    explain plan for
    select
    event_seq
    from v_dis_sub_har b 
    where
    --b.VZW_VENDOR_ID=200013
    --  and
    b.status='S'
    --and b.extract_date is null
    select plan_table_output from table(dbms_xplan.display)
    SQL>   2    3    4    5    6    7    8    9   10 
    Explained.
    SQL> SQL> SQL> SQL>   2 
    PLAN_TABLE_OUTPUT
    Plan hash value: 829738689
    | Id  | Operation                    | Name                         | Rows  | Bytes | Cost (%CPU)| T
    ime     |
    PLAN_TABLE_OUTPUT
    |   0 | SELECT STATEMENT             |                              | 20290 |   118K|  2772   (1)| 0
    0:00:34 |
    |   1 |  TABLE ACCESS BY INDEX ROWID | V_DIS_SUB_HAR                | 20290 |   118K|  2772   (1)| 0
    0:00:34 |
    |   2 |   BITMAP CONVERSION TO ROWIDS|                              |       |       |            |
            |
    |*  3 |    BITMAP INDEX SINGLE VALUE | V_DISPATCH_SUBSCRIPTION_NDX2 |       |       |            |
            |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       3 - access("B"."STATUS"='S')
    15 rows selected.
    SQL> SQL> set line 120
    SQL> /
    PLAN_TABLE_OUTPUT
    Plan hash value: 829738689
    | Id  | Operation                    | Name                         | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |                              | 20290 |   118K|  2772   (1)| 00:00:34 |
    |   1 |  TABLE ACCESS BY INDEX ROWID | V_DIS_SUB_HAR                | 20290 |   118K|  2772   (1)| 00:00:34 |
    |   2 |   BITMAP CONVERSION TO ROWIDS|                              |       |       |            |          |
    |*  3 |    BITMAP INDEX SINGLE VALUE | V_DISPATCH_SUBSCRIPTION_NDX2 |       |       |            |          |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       3 - access("B"."STATUS"='S')
    15 rows selected.
    SQL>
    explain plan for
    select
    event_seq
    from v_dis_sub_har b 
    where
    --b.VZW_VENDOR_ID=200013
    --  and
    b.status='P'
    --and b.extract_date is null
    select plan_table_output from table(dbms_xplan.display)
          SQL>   2    3    4    5    6    7    8    9   10 
    Explained.
    SQL> SQL> SQL> SQL>   2 
    PLAN_TABLE_OUTPUT
    Plan hash value: 2852398983
    | Id  | Operation         | Name          | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |               |  2325K|    13M|  5784  (18)| 00:01:10 |
    |*  1 |  TABLE ACCESS FULL| V_DIS_SUB_HAR |  2325K|    13M|  5784  (18)| 00:01:10 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       1 - filter("B"."STATUS"='P')
    13 rows selected.
    SQL>

  • Partition table not use index

    Hi Experts,
    Actually i have Production Partition table SMS_DELIVERY_NODETAILS its have partitions "PS_WD_01,PS_WD_02........... PS_WD_30". Partition base on date "TOOPERATOR" column like "10-11-2012 , 11-11-2012 ........".
    I have create local index "DELIVERY_CAMP" on "CAMPAIGN_NAME" column.
    I face issue in :
    case 1: Query using index "DELIVERY_CAMP" when i was use query with partition name "PS_WD_07"
    case 2: when query running with TOOPERATOR='2012-11-25' then table_sance_full.
    Oracle version =10g
    Os version = Linux 5.5
    SQL> DESC SMS_DELIVERY_NODETAILS
    Name                                                                                                              Null?    Type
    MSISDN                                                                                                                     VARCHAR2(15)
    TRANSACTIONID                                                                                                     NOT NULL VARCHAR2(50)
    TOOPERATOR                                                                                                                 VARCHAR2(25)
    FROMOPERATOR                                                                                                               VARCHAR2(25)
    STATUS                                                                                                                     VARCHAR2(25)
    TID_INDEX                                                                                                                  NUMBER
    CAMPAIGN_NAME                                                                                                              VARCHAR2(100)
    NETWORK_ERROR_CODE                                                                                                         VARCHAR2(20)
    Case 1:
    SQL> EXPLAIN PLAN FOR
      2  SELECT count(*) from SMS_DELIVERY_NODETAILS partition(PS_WD_07) where CAMPAIGN_NAME ='1353814653772_ftp_Churnscore100_pe_100';
    Explained.
    SQL> set line 200
    @?/rdbms/admin/utlxpls.sql
    SQL>
    PLAN_TABLE_OUTPUT
    Plan hash value: 2934568714
    | Id  | Operation               | Name          | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
    |   0 | SELECT STATEMENT        |               |     1 |    38 |    53   (0)| 00:00:01 |       |       |
    |   1 |  SORT AGGREGATE         |               |     1 |    38 |            |          |       |       |
    |   2 |   PARTITION RANGE SINGLE|               |  6320 |   234K|    53   (0)| 00:00:01 |    31 |    31 |
    |   3 |    PARTITION LIST ALL   |               |  6320 |   234K|    53   (0)| 00:00:01 |     1 |   100 |
    |*  4 |     INDEX RANGE SCAN    | DELIVERY_CAMP |  6320 |   234K|    53   (0)| 00:00:01 |  3001 |  3100 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       4 - access("CAMPAIGN_NAME"='1353814653772_ftp_Churnscore100_pe_100')
    16 rows selected.
    case 2:
    SQL> SQL> EXPLAIN PLAN FOR
      2  SELECT count(*) from SMS_DELIVERY_NODETAILS WHERE TOOPERATOR='2012-11-25' and  CAMPAIGN_NAME ='1353814653772_ftp_Churnscore100_pe_100';
    Explained.
    SQL> @?/rdbms/admin/utlxpls.sql
    PLAN_TABLE_OUTPUT
    Plan hash value: 3258763602
    | Id  | Operation               | Name                   | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
    |   0 | SELECT STATEMENT        |                        |     1 |    58 | 76394   (2)| 00:15:17 |       |       |
    |   1 |  SORT AGGREGATE         |                        |     1 |    58 |            |          |       |       |
    |   2 |   PARTITION RANGE SINGLE|                        |     1 |    58 | 76394   (2)| 00:15:17 |    31 |    31 |
    |   3 |    PARTITION LIST ALL   |                        |     1 |    58 | 76394   (2)| 00:15:17 |     1 |   100 |
    |*  4 |     TABLE ACCESS FULL   | SMS_DELIVERY_NODETAILS |     1 |    58 | 76394   (2)| 00:15:17 |  3001 |  3100 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       4 - filter("TOOPERATOR"='2012-11-25' AND "CAMPAIGN_NAME"='1353814653772_ftp_Churnscore100_pe_100')
    16 rows selected.

    Dear rp0428 ,
    1. the table and index DDL
    Table=>
    Table_name                     Partition_name                 Subpartition_name
    SMS_DELIVERY_NODETAILS         TOOPERATOR                     TID_INDEX
    Index=>
    create local index DELIVERY_TID_MSISDN_NODETAILS  on SMS_DELIVERY_NODETAILS(TRANSACTIONID,MSISDN);
    create local index DELIVERY_CAMP on SMS_DELIVERY_NODETAILS(CAMPAIGN_NAME);2. the query you used to collect the table and index stats
    SELECT count(*) from SMS_DELIVERY_NODETAILS WHERE TOOPERATOR='2012-11-25' and  CAMPAIGN_NAME ='1353814653772_ftp_Churnscore100_pe_100'; 3. the table, partition,subpartition row counts
    SQL> select PARTITION_POSITION,PARTITION_NAME,SUBPARTITION_COUNT,HIGH_VALUE from user_tab_partitions where TABLE_NAME='SMS_DELIVERY_NODETAILS' order by PARTITION_POSITION ;
    PARTITION_POSITION PARTITION_NAME                 SUBPARTITION_COUNT HIGH_VALUE
                     1 PS_WD_10                                      100 '2012-10-28'
                     2 PS_WD_11                                      100 '2012-10-29'
                     3 PS_WD_12                                      100 '2012-10-30'
                     4 PS_WD_13                                      100 '2012-10-31'
                     5 PS_WD_14                                      100 '2012-11-01'
                     6 PS_WD_15                                      100 '2012-11-02'
                     7 PS_WD_16                                      100 '2012-11-03'
                     8 PS_WD_17                                      100 '2012-11-04'
                     9 PS_WD_18                                      100 '2012-11-05'
                    10 PS_WD_19                                      100 '2012-11-06'
                    11 PS_WD_20                                      100 '2012-11-07'
    PARTITION_POSITION PARTITION_NAME                 SUBPARTITION_COUNT HIGH_VALUE
                    12 PS_WD_21                                      100 '2012-11-08'
                    13 PS_WD_22                                      100 '2012-11-09'
                    14 PS_WD_23                                      100 '2012-11-10'
                    15 PS_WD_24                                      100 '2012-11-11'
                    16 PS_WD_25                                      100 '2012-11-12'
                    17 PS_WD_26                                      100 '2012-11-13'
                    18 PS_WD_27                                      100 '2012-11-14'
                    19 PS_WD_28                                      100 '2012-11-15'
                    20 PS_WD_29                                      100 '2012-11-16'
                    21 PS_WD_30                                      100 '2012-11-17'
                    22 PS_WD_31                                      100 '2012-11-18'
    PARTITION_POSITION PARTITION_NAME                 SUBPARTITION_COUNT HIGH_VALUE
                    23 PS_WD_32                                      100 '2012-11-19'
                    24 PS_WD_01                                      100 '2012-11-20'
                    25 PS_WD_02                                      100 '2012-11-21'
                    26 PS_WD_03                                      100 '2012-11-22'
                    27 PS_WD_04                                      100 '2012-11-23'
                    28 PS_WD_05                                      100 '2012-11-24'
                    29 PS_WD_06                                      100 '2012-11-25'
                    30 PS_WD_07                                      100 '2012-11-26'
                    31 PS_WD_08                                      100 '2012-11-27'
                    32 PS_WD_09                                      100 '2012-11-28'
                    33 PS_WD_DEFAULT                                 100 MAXVALUE
    33 rows selected.

  • Not using Index when SDO_RELATE in Spatial Query is used in LEFT OUTER JOIN

    I want to know for every City (Point geometry) in which Municipality (Polygon geometry) it is.
    Some cities will not be covered by any municipality (as there is no data for it), so its municipality name should be blank in the result
    We have 4942 cities (point geometries)
    and 500 municipalities (polygon geometry)
    SELECT T1.NAME as City, T2.NAME as Municipality
    FROM CITY T1
    LEFT OUTER JOIN MUNICIPALITY T2 ON SDO_RELATE(T1.GEOM, T2.GEOM, 'MASK=ANYINTERACT') = 'TRUE'The explain plan for this query is:
    SELECT STATEMENT
      FILTER
        Filter Predicates
          MDSYS.SDO_RTREE_RELATE(T1.GEOM, T2.GEOM, 'mask=ANYINTERACT querytype=window ') = 'TRUE'
        MERGE JOIN
          TABLE ACCESS              CITY               FULL                            11
          BUFFER                                       SORT                        100605
              TABLE ACCESS          MUNICIPALITY       FULL                            20So the cost is in the BUFFER (whatever that is), it takes +2000 seconds to run this, it is not using the spatial index.
    And we are not getting all rows, but only the ones interacting with a municipality, e.g. 2436 rows.
    But I want all rows, including the ones not interacting with any Municipality.
    When we want only those cities that actually are in a municipality, I use a different query and it will use the index.
    SELECT T1.NAME as City, T2.NAME as Municipality
    FROM CITY T1, MUNICIPALITY T2
    WHERE SDO_RELATE(T1.GEOM, T2.GEOM, 'MASK=ANYINTERACT') = 'TRUE'I get (only) 2436 rows (as expected) in 5 seconds (it is fast) and the explain plan shows it is using the spatial index.
    But in this case, I am not getting any cities not inside any municipality (of course)
    SELECT STATEMENT
       NESTED LOOPS
          TABLE ACCESS                   MUNICIPALITY       FULL                22
          TABLE ACCESS                   CITY               BY INDEX ROWID      22
             DOMAIN INDEX                CITY_SDX                                0
                Access Predicates
                   MDSYS.SDO_RTREE_RELATE(T1.GEOM, T2.GEOM, 'mask=ANYINTERACT querytype=window ') = 'TRUE'I always thought a LEFT OUTER JOIN would return all rows from the Table, whatever happens in the next,
    but it seems the query has been rewritten so that it is now using a Filter Predicate in the end, which filters those geometries having no interaction.
    As an example I also do thing alphanumerically, I do get 4942 rows, including the ones which have no Municipality name.
    In this case the names must match, so its only for testing if the LEFT OUTER JOIN returns stuff correctly, which it does in this case.
    SELECT T1.NAME as City, T2.NAME as Municipality
    FROM CITY T1
    LEFT OUTER JOIN MUNICIPALITY T2 ON T1.NAME = T2.NAMEIs this an Oracle Spatial bug, e.g. not return 4942 rows, but only 2436 rows on the first query?
    Note all tests performed on Oracle 11g R2 (11.2.0.1.0)

    Patrick,
    Even so, your geoms in the relate were the wrong way around.
    Also, I don't recall you saying (or showing) that you wanted the municipality geometry returned. Still,
    no matter, easy to do.
    Here are some additional suggestions. I don't have your data so I have had to use some of my own.
    set serveroutput on timing on autotrace on
    SELECT T1.SPECIES as City,
           (SELECT T2.ADMIN_NAME FROM AUSTRALIAN_STATES T2 WHERE SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE') as Municipality,
           (SELECT T2.GEOM       FROM AUSTRALIAN_STATES T2 WHERE SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE') as geom
      FROM GUTDATA T1;
    762 rows selected
    Elapsed: 00:00:21.656
    Plan hash value: 2160035213
    | Id  | Operation                   | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |                            |   762 | 49530 |     5   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| AUSTRALIAN_STATES          |     1 |   115 |     0   (0)| 00:00:01 |
    |*  2 |   DOMAIN INDEX              | AUSTRALIAN_STATES_GEOM_SPX |       |       |     0   (0)| 00:00:01 |
    |   3 |  TABLE ACCESS BY INDEX ROWID| AUSTRALIAN_STATES          |     1 |   115 |     0   (0)| 00:00:01 |
    |*  4 |   DOMAIN INDEX              | AUSTRALIAN_STATES_GEOM_SPX |       |       |     0   (0)| 00:00:01 |
    |   5 |  TABLE ACCESS FULL          | GUTDATA                    |   762 | 49530 |     5   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE')
       4 - access("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE')
       Statistics
                   7  user calls
               24576  physical read total bytes
                   0  physical write total bytes
                   0  spare statistic 3
                   0  commit cleanout failures: cannot pin
                   0  TBS Extension: bytes extended
                   0  total number of times SMON posted
                   0  SMON posted for undo segment recovery
                   0  SMON posted for dropping temp segment
                   0  segment prealloc tasksThe above can look messy as you add more (SELECT ...) attributes, but is is fast (though can't use in Materialized Views).
    /* The set of all cities not in municipalities */
    SELECT T1.SPECIES                 as City,
           cast(null as varchar2(42)) as municipality,
           cast(null as sdo_geometry) as geom
      FROM GUTDATA T1
    WHERE NOT EXISTS (SELECT 1
                         FROM AUSTRALIAN_STATES T2
                        WHERE SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE')
    UNION ALL
    /* The set of all cities in municipalities */
    SELECT T1.SPECIES    as City,
           T2.ADMIN_NAME as Municipality,
           T2.GEOM       as geom
      FROM GUTDATA T1
           INNER JOIN
           AUSTRALIAN_STATES T2 ON (SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE');
    762 rows selected
    Elapsed: 00:00:59.953
    Plan hash value: 2854682795
    | Id  | Operation           | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |                            |    99 | 13450 |    38  (87)| 00:00:01 |
    |   1 |  UNION-ALL          |                            |       |       |            |          |
    |*  2 |   FILTER            |                            |       |       |            |          |
    |   3 |    TABLE ACCESS FULL| GUTDATA                    |   762 | 49530 |     5   (0)| 00:00:01 |
    |*  4 |    DOMAIN INDEX     | AUSTRALIAN_STATES_GEOM_SPX |       |       |     0   (0)| 00:00:01 |
    |   5 |   NESTED LOOPS      |                            |    61 | 10980 |    33   (0)| 00:00:01 |
    |   6 |    TABLE ACCESS FULL| AUSTRALIAN_STATES          |     8 |   920 |     3   (0)| 00:00:01 |
    |*  7 |    TABLE ACCESS FULL| GUTDATA                    |     8 |   520 |     4   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter( NOT EXISTS (SELECT 0 FROM "AUSTRALIAN_STATES" "T2" WHERE "MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE'))
       4 - access("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE')
       7 - filter("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"("T1"."GEOM",10000,0.5,'UNIT=M'))='TRUE')
       Statistics
                   7  user calls
              131072  physical read total bytes
                   0  physical write total bytes
                   0  spare statistic 3
                   0  commit cleanout failures: cannot pin
                   0  TBS Extension: bytes extended
                   0  total number of times SMON posted
                   0  SMON posted for undo segment recovery
                   0  SMON posted for dropping temp segment
                   0  segment prealloc tasksMuch slower but Materialized View friendly.
    This one is a bit more "natural" but still slower than the first.
    set serveroutput on timing on autotrace on
    /* The set of all cities in municipalities */
    WITH municipal_cities As (
      SELECT T1.ID         as City,
             T2.ADMIN_NAME as Municipality,
             T2.GEOM       as geom
        FROM GUTDATA T1
             INNER JOIN
             AUSTRALIAN_STATES T2 ON (SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE')
    SELECT T1.ID           as City,
           T2.Municipality as Municipality,
           T2.GEOM         as geom
      FROM GUTDATA          T1
           LEFT OUTER JOIN
           municipal_cities T2
           ON (T2.CITY = T1.ID);
    762 rows selected
    Elapsed: 00:00:50.228
    Plan hash value: 745978991
    | Id  | Operation             | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT      |                   |   762 | 44196 |    36   (3)| 00:00:01 |
    |*  1 |  HASH JOIN RIGHT OUTER|                   |   762 | 44196 |    36   (3)| 00:00:01 |
    |   2 |   VIEW                |                   |    61 |  3294 |    33   (0)| 00:00:01 |
    |   3 |    NESTED LOOPS       |                   |    61 | 10980 |    33   (0)| 00:00:01 |
    |   4 |     TABLE ACCESS FULL | AUSTRALIAN_STATES |     8 |   920 |     3   (0)| 00:00:01 |
    |*  5 |     TABLE ACCESS FULL | GUTDATA           |     8 |   520 |     4   (0)| 00:00:01 |
    |   6 |   INDEX FAST FULL SCAN| GUTDATA_ID_PK     |   762 |  3048 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - access("T2"."CITY"(+)="T1"."ID")
       5 - filter("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"("T1"."GEOM",10000,0.5,'UNIT=M'))='TRUE')
       Statistics
                   7  user calls
               49152  physical read total bytes
                   0  physical write total bytes
                   0  spare statistic 3
                   0  commit cleanout failures: cannot pin
                   0  TBS Extension: bytes extended
                   0  total number of times SMON posted
                   0  SMON posted for undo segment recovery
                   0  SMON posted for dropping temp segment
                   0  segment prealloc tasksFinally, the Pièce de résistance: trick the LEFT OUTER JOIN operator...
    set serveroutput on timing on autotrace on
    SELECT T1.SPECIES    as City,
           T2.ADMIN_NAME as Municipality,
           T2.GEOM       as geom
      FROM GUTDATA           T1
           LEFT OUTER JOIN
           AUSTRALIAN_STATES T2
           ON (t2.admin_name = to_char(t1.ID) OR
               SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE');
    762 rows selected
    Elapsed: 00:00:50.273
    Plan hash value: 158854308
    | Id  | Operation           | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |                   |   762 | 92964 |  2294   (1)| 00:00:28 |
    |   1 |  NESTED LOOPS OUTER |                   |   762 | 92964 |  2294   (1)| 00:00:28 |
    |   2 |   TABLE ACCESS FULL | GUTDATA           |   762 | 49530 |     5   (0)| 00:00:01 |
    |   3 |   VIEW              |                   |     1 |    57 |     3   (0)| 00:00:01 |
    |*  4 |    TABLE ACCESS FULL| AUSTRALIAN_STATES |     1 |   115 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - filter("T2"."ADMIN_NAME"=TO_CHAR("T1"."ID") OR
                  "MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"("T1"."GEOM",10000,0.5,'UNIT=M'))='TRUE')
       Statistics
                   7  user calls
                   0  physical read total bytes
                   0  physical write total bytes
                   0  spare statistic 3
                   0  commit cleanout failures: cannot pin
                   0  TBS Extension: bytes extended
                   0  total number of times SMON posted
                   0  SMON posted for undo segment recovery
                   0  SMON posted for dropping temp segment
                   0  segment prealloc tasksTry these combinations to see what works for you.
    Interestingly, for me, the following returns absolutely nothing.
    SELECT T1.SPECIES    as City,
           T2.ADMIN_NAME as Municipality
      FROM GUTDATA           T1
           LEFT OUTER JOIN
           AUSTRALIAN_STATES T2
           ON (SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE')
    MINUS
    SELECT T1.SPECIES    as City,
           T2.ADMIN_NAME as Municipality
      FROM GUTDATA           T1
           LEFT OUTER JOIN
           AUSTRALIAN_STATES T2
           ON (t2.admin_name =  to_char(t1.ID) OR
               SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE');(I leave it to you to see if you can see why as the LEFT OUTER JOIN seems to be working correctly for me but I am not going to dedicate time to detailed checking of results.)
    Note all tests performed on Oracle 11g R2 (11.2.0.1.0)
    If you get the answer you want: mark the post as answered to assign points.
    regards
    Simon

  • Delete not using indexes

    Hi, I'm a fairly new user of Oracle XMLDB 9.2.0.4 so please bear with me. I registered a schema and inserted about 130k rows into an XMLType table. Retrieval time took a severe hit as expected, but I created some indexes and it seemed to solve the problem. Autotrace showed that indexes were working correctly.
    However, delete does not seem to use those indexes, and instead performs a full table scan. The only difference between the statements used were:
    SELECT * FROM <table> where existsNode(...)
    DELETE FROM <table> where existsNode(...)
    Does anyone know how to alleviate full table scans on deletes?
    Thanks in advance,
    Justin

    Thanks for your time Mark.
    I messed around with 9.2.0.4 a little more, and realized that delete will use the index if it's an element that is indexed (like your example pointed out). However, delete doesn't seem to use indexed attributes.
    (Deleting based on an indexed element)
    explain plan for
    delete
    from purchaseorder x
    where existsNode ( value(x), '/PurchaseOrder/LineItems/LineItem[@ItemNumber="1"]/Part[@Id="715515011129"]') = 1
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes | Cost |
    | 0 | DELETE STATEMENT | | 1 | 19946 | 1 |
    | 1 | DELETE | PURCHASEORDER | | | |
    |* 2 | TABLE ACCESS BY INDEX ROWID| PURCHASEORDER | 1 | 19946 | 1 |
    |* 3 | INDEX RANGE SCAN | IPURCHASEORDERUSER | 2 | | 1 |
    (retrieving based on an indexed attribute)
    explain plan for
    select value(x)
    from purchaseorder x
    where existsNode ( value(x), '/PurchaseOrder/LineItems/LineItem[@ItemNumber="1"]/Part[@Id="715515011129"]') = 1
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes | Cost |
    | 0 | SELECT STATEMENT | | 1 | 24142 | 6 |
    |* 1 | INDEX RANGE SCAN | SYS_IOT_TOP_35381 | 1 | 2038 | 2 |
    |* 2 | INDEX RANGE SCAN | SYS_IOT_TOP_35386 | 1 | 4214 | 2 |
    | 3 | NESTED LOOPS | | 1 | 24142 | 6 |
    | 4 | SORT UNIQUE | | | | |
    |* 5 | INDEX UNIQUE SCAN | SYS_IOT_TOP_35386 | 1 | 4216 | 2 |
    |* 6 | INDEX RANGE SCAN | ILINEITEMPARTNUMBER | 1 | | 2 |
    |* 7 | TABLE ACCESS BY INDEX ROWID| PURCHASEORDER | 4 | 79704 | 1 |
    |* 8 | INDEX UNIQUE SCAN | SYS_C003455 | 102 | | |
    Predicate Information (identified by operation id):
    1 - access("SYS_NT5e0stCgbSQ6Dg7Md7+/Y0A=="."NESTED_TABLE_ID"=:B1)
    2 - access("SYS_NTyLtUmo5HRjCEB+0PWmS+kA=="."NESTED_TABLE_ID"=:B1)
    5 - access("SYS_NTyLtUmo5HRjCEB+0PWmS+kA=="."ITEMNUMBER"=1)
    filter("SYS_NTyLtUmo5HRjCEB+0PWmS+kA=="."SYS_NC00011$"='715515011129')
    6 - access("SYS_NTyLtUmo5HRjCEB+0PWmS+kA=="."ITEMNUMBER"=1)
    7 - filter(SYS_CHECKACL("SYS_ALIAS_4"."ACLOID","SYS_ALIAS_4"."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-pr
    operties/><read-contents/></privilege>''))=1)
    8 - access("SYS_NTyLtUmo5HRjCEB+0PWmS+kA=="."NESTED_TABLE_ID"="SYS_ALIAS_4"."SYS_N
    C0003400035$")
    Note: cpu costing is off
    (Deleting based on indexed attribute)
    explain plan for
    delete
    from purchaseorder x
    where existsNode ( value(x), '/PurchaseOrder/LineItems/LineItem[@ItemNumber="1"]/Part[@Id="715515011129"]') = 1
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes | Cost |
    | 0 | DELETE STATEMENT | | 1 | 19946 | 13 |
    | 1 | DELETE | PURCHASEORDER | | | |
    |* 2 | FILTER | | | | |
    |* 3 | TABLE ACCESS FULL | PURCHASEORDER | 1 | 19946 | 2 |
    |* 4 | COLLECTION ITERATOR PICKLER FETCH| | | | |
    Predicate Information (identified by operation id):
    2 - filter( EXISTS (SELECT /*+ */ 0 FROM
    TABLE(SYS_OP_ATG(SYS_OP_ATG(:B1,10,11,3),2,3,3)) "KOKBF$" WHERE
    SYS_OP_ATG(VALUE(KOKBF$),2,3,2)=1 AND SYS_OP_ATG(SYS_OP_ATG(VALUE(KOKBF$),4,5,3),2,3,2
    )='715515011129'))
    3 - filter(SYS_CHECKACL("SYS_ALIAS_4"."ACLOID","SYS_ALIAS_4"."OWNERID",xmltype(''<p
    rivilege 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"><update/>
    <unlink-from/></privilege>''))=1)
    4 - filter(SYS_OP_ATG(VALUE(KOKBF$),2,3,2)=1 AND
    SYS_OP_ATG(SYS_OP_ATG(VALUE(KOKBF$),4,5,3),2,3,2)='715515011129')
    Note: cpu costing is off
    Thanks again,
    Justin

  • Optimizer not using indexes

    DBAs,
    I have a select query which is using index scan when quired in prod. database and is executing in 20secs.and is using full table scan in non prod. db and is taking 48 secs.I rebuilded indexes & took stats in non-prod db but even it is taking 47 secs.
    Please advice......

    Here are the details
    EXECUTE DBMS_STATS.GATHER_SCHEMA_STATS( -ownname => 'TCD_PRD_STG', -
    estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE, -
    method_opt => 'for all columns size AUTO' -
    SQL> EXECUTE DBMS_STATS.GATHER_SCHEMA_STATS (‘JOE’,’EMPLOYEE’);
    EXECUTE DBMS_STATS.GATHER_SCHEMA_STATS('TCD_PRD_STG',DBMS_STATS.AUTO_SAMPLE_SIZE);
    1)Oracle versions are 10.2.0.2 in both prod & non-prod.
    2)Explain plan of prod. db
    SQL> SELECT ITEM_REFERENCE_ID FROM (SELECT DISTINCT * FROM ITEMS WHERE PUBLICATION_ID=20 AND ITEM_T
    YPE=16 AND ( ( ( SCHEMA_ID=31 ) ) AND ( ( (ITEM_REFERENCE_ID IN (SELECT ITEM_REFERENCE_ID FROM
    ( SELECT ITEM_REFERENCE_ID, COUNT(KEYWORD) AS tempkeywordcount FROM ITEM_CATEGORIES_AND_KEYWORDS WHE
    RE KEYWORD IN ('Africa') AND CATEGORY = 'Region' AND PUBLICATION_ID=20 GROUP BY ITEM_REFERENCE_ID) t
    empselectholder WHERE tempkeywordcount=1)) OR (ITEM_REFERENCE_ID IN (SELECT ITEM_REFERENCE_ID FROM (
    SELECT ITEM_REFERENCE_ID, COUNT(KEYWORD) AS tempkeywordcount FROM ITEM_CATEGORIES_AND_KEYWORDS WHER
    E KEYWORD IN ('Aig') AND CATEGORY = 'Region' AND PUBLICATION_ID=20 GROUP BY ITEM_REFERENCE_ID) temps
    electholder WHERE tempkeywordcount=1)) ) ) ) ORDER BY LAST_PUBLISHED_DATE DESC) WHERE ROWNUM<51;
    no rows selected
    Elapsed: 00:00:21.74
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=192 Card=50 Bytes=
    650)
    1 0 COUNT (STOPKEY)
    2 1 VIEW (Cost=192 Card=79 Bytes=1027)
    3 2 SORT (ORDER BY STOPKEY) (Cost=192 Card=79 Bytes=92272)
    4 3 HASH (UNIQUE) (Cost=191 Card=79 Bytes=92272)
    5 4 FILTER
    6 5 TABLE ACCESS (BY INDEX ROWID) OF 'ITEMS' (TABLE)
    (Cost=190 Card=808 Bytes=943744)
    7 6 INDEX (RANGE SCAN) OF 'IDX_ITEMS_PUB_URL' (IND
    EX) (Cost=107 Card=17024)
    8 5 FILTER
    9 8 HASH (GROUP BY) (Cost=42 Card=1 Bytes=540)
    10 9 TABLE ACCESS (BY INDEX ROWID) OF 'ITEM_CATEG
    ORIES_AND_KEYWORDS' (TABLE) (Cost=41 Card=1 Bytes=540)
    11 10 INDEX (RANGE SCAN) OF 'IX_ITEM_KEYWORDS' (
    INDEX) (Cost=35 Card=7403)
    12 5 FILTER
    13 12 HASH (GROUP BY) (Cost=3 Card=1 Bytes=540)
    14 13 TABLE ACCESS (BY INDEX ROWID) OF 'ITEM_CATEG
    ORIES_AND_KEYWORDS' (TABLE) (Cost=2 Card=1 Bytes=540)
    15 14 INDEX (RANGE SCAN) OF 'IX_ITEM_KEYWORDS' (
    INDEX) (Cost=1 Card=50)
    Statistics
    21 recursive calls
    0 db block gets
    4950582 consistent gets
    4060 physical reads
    13100 redo size
    240 bytes sent via SQL*Net to client
    333 bytes received via SQL*Net from client
    1 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    0 rows processed
    explain plan of non-prod db
    1* SELECT ITEM_REFERENCE_ID FROM (SELECT DISTINCT * FROM ITEMS WHERE PUBLICATION_ID=20 AND ITEM_T
    SQL> /
    ITEM_REFERENCE_ID
    96672
    96680
    Elapsed: 00:00:47.74
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=502 Card=50 Bytes=
    650)
    1 0 COUNT (STOPKEY)
    2 1 VIEW (Cost=502 Card=255 Bytes=3315)
    3 2 SORT (ORDER BY STOPKEY) (Cost=502 Card=255 Bytes=40035
    4 3 HASH (UNIQUE) (Cost=501 Card=255 Bytes=40035)
    5 4 FILTER
    6 5 TABLE ACCESS (FULL) OF 'ITEMS' (TABLE) (Cost=500
    Card=2618 Bytes=411026)
    7 5 FILTER
    8 7 HASH (GROUP BY) (Cost=881 Card=1 Bytes=29)
    9 8 TABLE ACCESS (FULL) OF 'ITEM_CATEGORIES_AND_
    KEYWORDS' (TABLE) (Cost=880 Card=11 Bytes=319)
    10 5 FILTER
    11 10 HASH (GROUP BY) (Cost=881 Card=1 Bytes=29)
    12 11 TABLE ACCESS (FULL) OF 'ITEM_CATEGORIES_AND_
    KEYWORDS' (TABLE) (Cost=880 Card=1 Bytes=29)
    Statistics
    0 recursive calls
    0 db block gets
    5912606 consistent gets
    0 physical reads
    0 redo size
    387 bytes sent via SQL*Net to client
    435 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    2 rows processed

Maybe you are looking for

  • HT5096 How can I move my Time Capsule Backup to an External Hard Drive?

    Hi I have run out of space on my Time Capsule so have decided to change my backup drive to an external hard drive of 4TB. I moved the Sparse Disk Image Bundle from the Time Capsule to the new drive and then changed Time Machine preferences to use the

  • How do I revert my iPhoto to the Original File?

    I have Mac OS X - Version 10.5.8 - iPhoto 9 I have a numerious amount of photo's that look fine in thumbnail but when opened I am given a "!".  I have done the suggested Command+Option keys held down and rebuild the library.  This did not work!  But

  • What is the setting for Siri to give audible turn by turn directions?

    Have figured out how to get turn by turn directions but they are not audible.  Keep missing turns while trying to read on phone.  Not the safest way to drive.

  • SetSize problem!

    hi all Is there any reason for setSize doesn�t work? i dont why, its not working for me! :-( i have a class which extends JFrame and ihv added setSize(600,500) in constructor, juzt after super(title) ! someone please help me! thanks and regards sarat

  • Email sent not in sent mail.

    Email sent not in sent mail, where I find them?