Forcing to use index

I have a query which is taking 2 minutes to respond. When I see the explain plan, it said for two tables it is doing the full table scan. So I tried forcing to use the index on the inner tables(xcm, detail) of the views(vw_xcm , vw_vw_detail). But it is still not using indexes when the query is running. Please let me know if I am forcing the indexes right.
Here is my code
SELECT x.customer_gci AS hdr_borrower_gci,
                x.industry_group_name AS hdr_borrower_sector,
                x.industry_subgroup_name AS hdr_borrower_industry,
                CAST (NULL AS number) AS hdr_incremental_fvo_amt,
                x.industry_subgroup_code AS hdr_industry_cd,
                x.industry_subgroup_name AS hdr_industry,
                CAST (NULL AS integer) AS hdr_cds_tenor,
                x.industry_group_code AS hdr_req_borrower_sector_cd,
                x.industry_subgroup_code AS hdr_req_borrower_industry_cd,
                x.customer_gci AS dtl_borrower_gci,
                x.customer_name AS dtl_company_name,
                (SELECT NVL (MAX (market_cap), 0)
                 FROM data_v2 kmv
                 WHERE     kmv.asof_date = (SELECT MAX (actual_data_date)
                                            FROM fvo_process_dtl dtl
                                            WHERE dtl.process_name = 'KMV')
                       AND kmv.spineid = x.spineid
                       AND kmv.market_cap <> 0)
                   AS dtl_marketcap,
                x.industry_subgroup_name AS dtl_industry,
                x.dtl_region,
                (SELECT SUM (NVL (notional, 0))
                 FROM vw_gcm
                 WHERE     datestamp = (SELECT MAX (datestamp)
                                        FROM vw_fvo_gcm_trade)
                       AND familygci = family_gci
                       AND rpt_product = 'LOAN'
                       AND rpt_risk_group = 'FVO')
                   AS dtl_current_fvo_amt,
                NULL AS dtl_trader_liquidity_cd,
                CAST (NULL AS number) AS dtl_manager_acceptable_amt,
                NULL AS dtl_lastused_date,
                NULL AS dtl_trader_comments,
                NULL AS dtl_manager_comments,
                CAST (NULL AS number) AS dtl_incremental_fvo_amt,
                x.industry_subgroup_code AS dtl_industry_code,
                x.spineid,
                (SELECT SUBSTR (MAX(TO_CHAR (ratingdate, 'YYYYMMDD')
                                    || iss.issuerrating),
                                9
                 FROM issuerrating iss
                 WHERE iss.ratingschemeid =
                          (SELECT rs.ratingschemeid
                           FROM ratingscheme rs
                           WHERE rs.ratingschemename = 'SNP')
                       AND iss.ratingtypeid = (SELECT rt.ratingtypeid
                                               FROM ratingtype rt
                                               WHERE rt.ratingtypecode = 'LT')
                       AND iss.ratingdate <= TRUNC (SYSDATE)
                       AND iss.issuerrating NOT IN
                                ('NR',
                                 'WR',
                                 'SD',
                                 'NM',
                                 'NRpi',
                                 'Rpi',
                                 'R',
                                 'SDpi')
                       AND iss.spineid = x.spineid)
                   AS dtl_snp_rating,
                (SELECT SUBSTR (MAX(TO_CHAR (ratingdate, 'YYYYMMDD')
                                    || iss.issuerrating),
                                9
                 FROM rating iss
                 WHERE iss.ratingschemeid =
                          (SELECT rs.ratingschemeid
                           FROM rating rs
                           WHERE rs.ratingschemename = 'MOODYS')
                       AND iss.ratingtypeid = (SELECT rt.ratingtypeid
                                               FROM ratingtype rt
                                               WHERE rt.ratingtypecode = 'LT')
                       AND iss.ratingdate <= TRUNC (SYSDATE)
                       AND iss.issuerrating NOT IN ('NR', 'WR', 'SD')
                       AND iss.spineid = x.spineid)
                   AS dtl_moodys_rating,
                risk_rating AS dtl_internal_rating
         FROM (SELECT /* + INDEX(xcm fvo_xcm_customer_ix3) INDEX(id fvo_ecris_d_industry_dtl_ix1)*/ xcm.customer_gci AS customer_gci,
                      xcm.customer_name AS customer_name,
                      TRIM (REPLACE (id.industry_group_name, '"', ' '))
                         AS industry_group_name,
                      id.industry_group_code,
                      TRIM (REPLACE (id.industry_subgroup_name, '"', ' '))
                         AS industry_subgroup_name,
                      id.industry_subgroup_code,
                      TRIM (REPLACE (id.industry_subgroup_name, '"', ' '))
                         AS dtl_industry,
                      (SELECT threealphacountrycode
                       FROM xcm_region_country_map r
                       WHERE     r.twoalphacountrycode = xcm.country_code
                             AND r.regioncode != 'INTL'
                             AND r.region IN ('North American', 'EMEA'))
                         AS dtl_region,
                      (SELECT spineid
                       FROM companymap cm
                       WHERE     cm.sourcereferenceid = 24
                             AND cm.sourcereferencevalue = xcm.customer_gci
                             AND cm.enddate IS NULL)
                         AS spineid,
                      xcm.family_gci AS family_gci,
                      xcm.risk_rating AS risk_rating
               FROM vw_xcm xcm,
                    (SELECT naics_code,
                            industry_group_name,
                            industry_group_code,
                            industry_subgroup_name,
                            industry_subgroup_code
                     FROM vw_detail
                     WHERE industry_subgroup_code IS NOT NULL) id
               WHERE     xcm.period = (SELECT MAX (period)
                                       FROM vw_xcm)
                     --                                  AND xcm.industry_detail_key =
                     --                                        id.industry_detail_key
                     AND xcm.naics_code = id.naics_code
                    AND TRIM (xcm.customer_gci) NOT LIKE 'S%') x
{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Sometimes the cost-based optimizer will not take hints because it thinks it knows better. This is a matter of debate here on OTN, where some posters dogmatically assert that hints are instructions that must be followed. My experience is different. I have on rare occasions used perfectly good hints (usually INDEX) that the database simply refused to use.
Someone noted on a post a month or two ago that there may be a glitch with the CBO where it loses indexes when considering execution plans. This was based on a 10053 trace, which will show the different access paths considered during query evaluation.
Ultimately the CBO is deciding you query is more efficient not to use the indexes, even with your hint.
Looking again at your query I'll note that it is very complicated with inline views and more inline views. The CBO has trouble running multiple views efficiently - inline views, views of views, views joined to views - because views have no valid statistics associated with them. The choices the CBO makes based on views use defaults that are all but certain to be incorrect.
In particular, your index use for "id" makes no sense because it is an inline view. you could try using a global hint by pushing the hint inside the view, something like
INDEX(id.table_in_view fvo_ecris_d_industry_dtl_ix1)Unfortunately, the table inside the inline view id itself appears to be a view compliating this effort.
Try using the USE_NL hint instead of INDEX and see if that helps
Good luck

Similar Messages

  • Can Oracle be forced to use the spatial index for sdo_filter in combination with an or clause? Difference between Enterprise and SE?

    We’re seeing the following issue: sql - Can Oracle be forced to use the spatial index for sdo_filter in combination with an or clause? - Stack Overflow (posted by a colleague of mine) and are curious to know if this behaviour is due to a difference between standard and enterprise, or could we doing something else wrong in our DB config.?
    We have also reproduced the issue on the following stacks:
    Oracle SE One 11.2.0.3 (with Spatial enabled)
    Redhat Linux 2.6.32-358.6.2.el6.x86_64 #1 SMP Thu May 16 20:59:36 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
    11.2.0.3.0 Standard Edition and 11.2.0.4.0 Standard Edition (both with Spatial enabled)
    Microsoft Windows Server 2003R2 Standard x64 Edition
    However, the SQL works fine if we try it on Oracle 11.2.0.3.0 *Enterprise* Edition.
    Any help or advice would be much appreciated.
    Kindest Regards,
    Kevin

    In my experience sdo_filter ALWAYS uses the spatial index, so that's not the problem. Since you did not provide the explain plans, we can't say for sure but I think yhu is right: Standard Edition can't use the bitmap operations, and thus it'll take longer to combine the results of the two queries (because the optimizer will surely split this OR up in two parts, then combine them).
    BTW: when asking questions about queries here, it would be nice if you posted the queries here as well, so that we do not have to check another website in order to see what you are doing. Plus it will probably get you more answers, because not everyone can be bothered to click on that link. It would also have been nice if you had posted your own answer on the other post here as well, because my recommendation would have been to use union all - but since you already found that out for yourself my recommendation would have been a little late.

  • Query tuning and how to force  table to use index?

    Dear Experts,
    i have two (2) question regarding performance during DRL.
    Question # 1
    There is a column name co_id in every transaction table. DBA suggest me to add [co_id='KPG'] in every clause which forces query to use index, resulting immediate processing. As an index was created for each table on the co_id column.
    Please note that co_id has constant value 'KPG' through out the table. is it make sense to add that column in where caluse like
    select a,b,c from tab1
    where a='89' and co_id='KPG'
    Question # 2
    if i am using a column name in where clause having index on it and that column is not in my column list does it restrict query for full table scan. like
    select a,b,c,d from tabletemp
    where e='ABC';
    Thanks in advance
    Edited by: Fiz Dosani on Mar 27, 2009 12:00 PM

    Fiz Dosani wrote:
    Dear Experts,
    i have two (2) question regarding performance during DRL.
    Question # 1
    There is a column name co_id in every transaction table. DBA suggest me to add [co_id='KPG'] in every clause which forces query to use index, resulting immediate processing. As an index was created for each table on the co_id column.
    Please note that co_id has constant value 'KPG' through out the table. is it make sense to add that column in where caluse like
    select a,b,c from tab1
    where a='89' and co_id='KPG'If co_id is always 'KPG' it is not needed to add this condition to the table. It would be very stupid to add an (normal) index on that column. An index is used to reduce the resultset of a query by storing the values and the rowids in a specified order. When all the values are equal and index justs makes all dml operations slower without makeing any select faster.
    And of cause the CBO is clever enough not to use such a index.
    >
    Question # 2
    if i am using a column name in where clause having index on it and that column is not in my column list does it restrict query for full table scan. like
    select a,b,c,d from tabletemp
    where e='ABC';
    Yes this is possible. However it depends from a few things.
    1) How selective this condition is. In general an index will be used when selectivity is less than 5%. This factor depends a bit on the database version. it means that when less then 5% of your rows have the value 'ABC' then an index access will be faster than the full table scan.
    2) Are the statistics up to date. The cost based optimizer (CBO) needs to know how many values are in that table, in the columns, in that index to make a good decision bout using an index access or a full table scan. Often one forgets to create statistics for freshly created data as in temptables.
    Edited by: Sven W. on Mar 27, 2009 8:53 AM

  • How to compile the hint to force selection statement to use index

    Hello expert,
    will you please tell me how to compile the hint to force selection statement to use index?
    Many Thanks,

    Not sure what you mean by compile, but hint is enclosed in /*+ hint */. Index hint is INDEX(table_name,index_name). For example:
    SQL> explain plan for
      2  select * from emp
      3  /
    Explained.
    SQL> @?\rdbms\admin\utlxpls
    PLAN_TABLE_OUTPUT
    Plan hash value: 3956160932
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |    14 |   546 |     3   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| EMP  |    14 |   546 |     3   (0)| 00:00:01 |
    8 rows selected.
    SQL> explain plan for
      2  select /*+ index(emp,pk_emp) */ *
      3  from emp
      4  /
    Explained.
    SQL> @?\rdbms\admin\utlxpls
    PLAN_TABLE_OUTPUT
    Plan hash value: 4170700152
    | Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |        |    14 |   546 |     2   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |    14 |   546 |     2   (0)| 00:00:01 |
    |   2 |   INDEX FULL SCAN           | PK_EMP |    14 |       |     1   (0)| 00:00:01 |
    9 rows selected.
    SQL> Hint in the above example is forcing optimizer to use index which resul;ts in a bad execution plan. Most of the time optimizer does not need hints and chooses an optimal plan. In most cases sub-optimal plan is result of stale or incomplete statistics.
    SY.

  • Using index and NULL

    Hi,
    I have the following issue (10.2.0.4)
    I have index on NO0_SESSION_ID and TBNAME
    how can I force using index ?
    Thanks for your help
    UPDATE BXAT.no5                                    
       SET TBNAME = :p0,                               
           REPLICATION_METHOD = :p1,                   
           STATUS = :p2,                               
           STARTING_TIME = :p3,                        
           ENDING_TIME = :p4,                          
           REC_INSERTED = :p5,                         
           REC_UPDATED = :p6,                          
           REC_UNCHANGED = :p7,                        
           REC_IN_ERROR = :p8,                         
           REC_CONFLICTS = :p9,                        
           TOTAL_REC = :p10,                           
           REC_CONF_UPDATED = :p11,                    
           REC_CONF_UNCHANGED = :p12,                  
           MASTER_TABLE = :p13,                        
           MASTER_SQ0_NRID = :p14,                     
           NO0_SESSION_ID = :p15,                      
           REC_PURGED = :p16,                          
           SQ0_NRID = :p17                             
    WHERE     (NO0_SESSION_ID = :wp18 OR :wp18 IS NULL)
           AND (TBNAME = :wp19 OR :wp19 IS NULL)              
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | UPDATE STATEMENT   |      |  1723 | 96488 |  1361   (1)| 00:00:17 |
    |   1 |  UPDATE            | NO5  |       |       |            |          |
    |*  2 |   TABLE ACCESS FULL| NO5  |  1723 | 96488 |  1361   (1)| 00:00:17 |
    Predicate Information (identified by operation id):                       
       2 - filter((:WP19 IS NULL OR "TBNAME"=:WP19) AND (:WP18 IS NULL OR     
                  "NO0_SESSION_ID"=TO_NUMBER(:WP18)))                         

    user12045475 wrote:
    Hi,
    I have the following issue (10.2.0.4)
    I have index on NO0_SESSION_ID and TBNAME
    how can I force using index ?
    Thanks for your help
    UPDATE BXAT.no5                                    
    SET TBNAME = :p0,                               
    REPLICATION_METHOD = :p1,                   
    STATUS = :p2,                               
    STARTING_TIME = :p3,                        
    ENDING_TIME = :p4,                          
    REC_INSERTED = :p5,                         
    REC_UPDATED = :p6,                          
    REC_UNCHANGED = :p7,                        
    REC_IN_ERROR = :p8,                         
    REC_CONFLICTS = :p9,                        
    TOTAL_REC = :p10,                           
    REC_CONF_UPDATED = :p11,                    
    REC_CONF_UNCHANGED = :p12,                  
    MASTER_TABLE = :p13,                        
    MASTER_SQ0_NRID = :p14,                     
    NO0_SESSION_ID = :p15,                      
    REC_PURGED = :p16,                          
    SQ0_NRID = :p17                             
    WHERE     (NO0_SESSION_ID = :wp18 OR :wp18 IS NULL)
    AND (TBNAME = :wp19 OR :wp19 IS NULL)              
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | UPDATE STATEMENT   |      |  1723 | 96488 |  1361   (1)| 00:00:17 |
    |   1 |  UPDATE            | NO5  |       |       |            |          |
    |*  2 |   TABLE ACCESS FULL| NO5  |  1723 | 96488 |  1361   (1)| 00:00:17 |
    Predicate Information (identified by operation id):                       
    2 - filter((:WP19 IS NULL OR "TBNAME"=:WP19) AND (:WP18 IS NULL OR     
    "NO0_SESSION_ID"=TO_NUMBER(:WP18)))                         
    It has already been pointed out that the FTS is probably due to the OR whatever IS NULL predicates.
    A hack that might/might not work - assuming indexes on the columns exist - is to use the syntax
    --'' is an empty string, interpreted by Oracle as null
    +column+ > ''A better way is to create a function-based index using NVL() or COALECSE on the affected column.

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

  • 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

  • I'm a MB Pro beginner (after 25 years with PC). I have an Iomega ext HD, but how do get it indexed. I'm trying searches in Finder, and it says "searching Iomega drive" - but I don't think it's indexing. How do I force it to index?

    I'm a MB Pro beginner (after 25 years with PC). I have an Iomega ext HD, but how do get it indexed?, and it doesn't come up with any results I'm trying searches in Finder, and it says "searching Iomega drive" - but I don't think it's indexing. How do I force it to index?

    Well I'm leaning the other way. I think my present MBP will be the last Apple product I buy.
    With the way Apple is going, all New Mac computers are sealed unit that don't allow the user to upgrade them in any way. They are getting more expensive initially. They are impossible to fix, even by Apple. All the parts are either soldered to the Logic Board or glued inside the case parts. The add on warranty only covers manufacturing defects and is expensive. And to fix one out of waranty is close to if not more then a new system.
    The only thing different in a Mac, and most other products Apple sells, is the operating system and the cases they come in. As for the OS both have their glitches and at this time there are no viruses that infect OS X. There is more software available for Windows. More choices as to what hardware you can use or upgrade to at a later date.
    Mac computers are becoming large iPads or iPhones with built in keyboards.
    jeremy_from_rome wrote:
    And as for the question: PC or Mac, the consensus that I hear from colleagues and friends is just as you state it: stay with Mac, be patient, work at it, and you’ll never look back! Thanks again

  • CBO calculates un acceptable cost while using index.

    Hi,
    I was wondering to see the execution plan for both the case using index/without index.
    We are using oracle 10G(10.2.0.3.0) with RAC in production at O/S:- sun solaris 10.
    Java based application is running in this database. One of the sql query is taking long time to fetch the records. I analyzed the sql plan and noticed the FTS. I created indexes to the column(s) which is refering in where clauses. I noticed a strage behavior. Execution plan shows that the CBO is using right path but its not acceptable as application is time outs while return the rows.
    first execution plan with/without index (not using the index).
    PLAN_TABLE_OUTPUT
    Plan hash value: 419342726
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 196 | 3332 | 67845 (3)| 00:13:35 |
    |* 1 | TABLE ACCESS FULL | CWDBENUMDESCRIPTIONS | 1 | 35 | 3 (0)| 00:00:01 |
    | 2 | SORT GROUP BY | | 196 | 3332 | 67845 (3)| 00:13:35 |
    |* 3 | TABLE ACCESS FULL| CWORDERINSTANCE | 51466 | 854K| 67837 (3)| 00:13:35 |
    Predicate Information (identified by operation id):
    1 - filter("ERR"."CODE"=:B1)
    3 - filter("OI"."ERROR_CODE" IS NOT NULL AND "OI"."DIVISION"='OR9' AND
    "OI"."ACTIVE"=TO_NUMBER(:1) AND "OI"."ORDER_STATE"<>'O_NR_NS' AND
    "OI"."ORDER_STATE"<>'C_C_QR' AND "OI"."ORDER_STATE"<>'O_NR_NS_D')
    SQl query was modified to force the index to use /*+ index(oi oi_div) */ the execution is as below:-
    PLAN_TABLE_OUTPUT
    Plan hash value: 1157277132
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 196 | 3332 | 394K (1)| 01:18:52 |
    |* 1 | TABLE ACCESS FULL | CWDBENUMDESCRIPTIONS | 1 | 35 | 3 (0)| 00:00:01 |
    | 2 | SORT GROUP BY | | 196 | 3332 | 394K (1)| 01:18:52 |
    |* 3 | TABLE ACCESS BY INDEX ROWID| CWORDERINSTANCE | 51466 | 854K| 394K (1)| 01:18:52 |
    |* 4 | INDEX RANGE SCAN | OI_DIV | 3025K| | 14226 (1)| 00:02:51 |
    Predicate Information (identified by operation id):
    1 - filter("ERR"."CODE"=:B1)
    3 - filter("OI"."ERROR_CODE" IS NOT NULL AND "OI"."ACTIVE"=TO_NUMBER(:1) AND
    "OI"."ORDER_STATE"<>'O_NR_NS' AND "OI"."ORDER_STATE"<>'C_C_QR' AND
    "OI"."ORDER_STATE"<>'O_NR_NS_D')
    My questions are here:-
    1). why FTS is less costly comparing index scan where there are 15000000 rows in the table.
    2). while forcing index to use cost increase drastically (the statistics is latest one analyzed on 6th of feb 2009)
    3). what should i suppose to change to get the performance benefit.
    Thanks,
    Pradeep

    user587112 wrote:
    select null, oi.division, oi.METADATATYPE, oi.ERROR_CODE,
           (  select err.DESCRIPTION
    FROM   CWDBENUMDESCRIPTIONS err
    WHERE  oi.ERROR_CODE = err.CODE
    count(*)
    from CWORDERINSTANCE oi
    where
         oi.ERROR_CODE is not null
          and oi.division in ('BK9')
         and oi.order_state not in ('O_NR_NS_D', 'C_C_QR', 'O_NR_NS')
          and oi.metadatatype = :1
         and oi.duedate>=:2
         and oi.active = :3
    group by oi.division, oi.metadatatype, oi.error_code
    order by oi.division, oi.metadatatype, oi.error_code
    In this query, if we use as it is how its being displayed, it runs like a rocket, but if we change division in ('OR9') instead of 'BK9' it does not use index and leads to time out the application.
    Number of records   division
    1964690                             ---------------- why this field is null ?
    3090666              OR9
    3468                 BA9
    1242                 EL9
    2702                 IN9
    258                  EU9
    196198               DT9
    1268                 PA9
    8                    BK9
    2332                 BH9
    1405009              TP9
    According to the stats in your original execution plan, it looks like you have a histogram on this column, and the index you want to use is on just the division column.
    Oracle estimate for 'OR9' is 3M rowids from the index, resulting in 50,000+ rows from the table - that's a lot of work - it's not surprising that the optimizer chose a tablescan for 'OR9' - but chose to use the index for 'BK9' which has only 8 rows.
    How often do you want to run this query ? And how accurate does the answer have to be ?
    If you want this query to run faster even when it's processing a huge number of rows, one option would be to create a materialized view over the data that could supply the result set much more efficiently (possibly getting your front-end code to call a materialized view refresh before running the query).
    The only other altenative is probably to create an index that covers all the columns in the query so that you don't have to visit the table - and if you order them correctly you won't have to do a sort group by. I think this index should do the trick: (division, metadatatype, error_code,active, duedate,orderstate). You could also compress this index on at least the first column, but possibly on far more columns, to minimise the size,
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    "The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge."
    Stephen Hawking
    To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Want to use Index in Select statement

    Hi,
    I want to use the index tha is created for LIPS table for creation date. I want to use that INdex in the select statement to get the data from that table. Any one can tell me how can I right the select statement in report?
    thanks.

    Like I mentioned earlier, the optimizer is smart enough to choose the correct index based on the WHERE clause.  So if you created an index on field ERDAT for LIPS and your SELECT statement is like so.....
    Select ERDAT WERKS MATNR
              from LIPS
                          into table Itab
                                    Where erdat in s_erdat        "< - ERDAT First in WHERE Clause
                                        and werks in s_werks
                                        and Matnr in s_matnr.
    Then the optimizer will choose your index to use to access the data.  You can see these if you would do an SQL trace over your program and use the "Explain" button on ST05.  It will tell you which index it used and why.
    There is no need to use HINTs to force the use of the index.
    Regards,
    Rich Heilman

  • How to make sql to use index/make to query to perform better

    Hi,
    I have 2 sql query which results the same.
    But both has difference in SQL trace.
    create table test_table
    (u_id number(10),
    u_no number(4),
    s_id number(10),
    s_no number(4),
    o_id number(10),
    o_no number(4),
    constraint pk_test primary key(u_id, u_no));
    insert into test_table(u_id, u_no, s_id, s_no, o_id, o_no)
    values (2007030301, 1, 1001, 1, 2001, 1);
    insert into test_table(u_id, u_no, s_id, s_no, o_id, o_no)
    values (2007030302, 1, 1001, 1, 2001, 2);
    insert into test_table(u_id, u_no, s_id, s_no, o_id, o_no)
    values (2007030303, 1, 1001, 1, 2001, 3);
    insert into test_table(u_id, u_no, s_id, s_no, o_id, o_no)
    values (2007030304, 1, 1001, 1, 2001, 4);
    insert into test_table(u_id, u_no, s_id, s_no, o_id, o_no)
    values (2007030305, 1, 1002, 1, 1001, 2);
    insert into test_table(u_id, u_no, s_id, s_no, o_id, o_no)
    values (2007030306, 1, 1002, 1, 1002, 1);
    commit;
    CREATE INDEX idx_test_s_id ON test_table(s_id, s_no);
    set autotrace on
    select s_id, s_no, o_id, o_no
    from test_table
    where s_id <> o_id
    and s_no <> o_no
    union all
    select o_id, o_no, s_id, s_no
    from test_table
    where s_id <> o_id
    and s_no <> o_no;
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=6 Card=8 Bytes=416)
    1 0 UNION-ALL
    2 1 TABLE ACCESS (FULL) OF 'TEST_TABLE' (TABLE) (Cost=3 Card=4 Bytes=208)
    3 1 TABLE ACCESS (FULL) OF 'TEST_TABLE' (TABLE) (Cost=3 Card=4 Bytes=208)
    Statistics
    223 recursive calls
    2 db block gets
    84 consistent gets
    0 physical reads
    0 redo size
    701 bytes sent via SQL*Net to client
    508 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    5 sorts (memory)
    0 sorts (disk)
    8 rows processed
    -- i didnt understand why the above query is not using the index idx_test_s_id.
    -- But still it is faster
    select s_id, s_no, o_id, o_no
    from test_table
    where (u_id, u_no) in
    (select u_id, u_no from test_table
    minus
    select u_id, u_no from test_table
    where s_id = o_id
    or s_no = o_no)
    union all
    select o_id, o_no, s_id, s_no
    from test_table
    where (u_id, u_no) in
    (select u_id, u_no from test_table
    minus
    select u_id, u_no from test_table
    where s_id = o_id
    or s_no = o_no);
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=16 Card=2 Bytes=156)
    1 0 UNION-ALL
    2 1 FILTER
    3 2 TABLE ACCESS (FULL) OF 'TEST_TABLE' (TABLE) (Cost=3 Card=6 Bytes=468)
    4 2 MINUS
    5 4 INDEX (UNIQUE SCAN) OF 'PK_TEST' (INDEX (UNIQUE)) (Cost=1 Card=1 Bytes=26)
    6 4 TABLE ACCESS (BY INDEX ROWID) OF 'TEST_TABLE' (TABLE) (Cost=2 Card=1 Bytes=78)
    7 6 INDEX (UNIQUE SCAN) OF 'PK_TEST' (INDEX (UNIQUE)) (Cost=1 Card=1)
    8 1 FILTER
    9 8 TABLE ACCESS (FULL) OF 'TEST_TABLE' (TABLE) (Cost=3 Card=6 Bytes=468)
    10 8 MINUS
    11 10 INDEX (UNIQUE SCAN) OF 'PK_TEST' (INDEX (UNIQUE)) (Cost=1 Card=1 Bytes=26)
    12 10 TABLE ACCESS (BY INDEX ROWID) OF 'TEST_TABLE' (TABLE) (Cost=2 Card=1 Bytes=78)
    13 12 INDEX (UNIQUE SCAN) OF 'PK_TEST' (INDEX (UNIQUE)) (Cost=1 Card=1)
    Statistics
    53 recursive calls
    8 db block gets
    187 consistent gets
    0 physical reads
    0 redo size
    701 bytes sent via SQL*Net to client
    508 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    4 sorts (memory)
    0 sorts (disk)
    8 rows processed
    -- The above query is using index PK_TEST. But still it has FULL SCAN to the
    -- table two times it has the more cost.
    1st query --> SELECT STATEMENT Optimizer=ALL_ROWS (Cost=6 Card=8 Bytes=416)
    2nd query --> SELECT STATEMENT Optimizer=ALL_ROWS (Cost=16 Card=2 Bytes=156)
    My queries are:
    1) performance wise which query is better?
    2) how do i make the 1st query to use an index
    3) is there any other method to get the same result by using any index
    Appreciate your immediate help.
    Best regards
    Muthu

    Hi William
    Nice...it works.. I have added "o_id" and "o_no" are in part of the index
    and now the query uses the index
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=2 Card=8 Bytes=416)
    1 0 UNION-ALL
    2 1 INDEX (FULL SCAN) OF 'IDX_TEST_S_ID' (INDEX) (Cost=1 Card=4 Bytes=208)
    3 1 INDEX (FULL SCAN) OF 'IDX_TEST_S_ID' (INDEX) (Cost=1 Card=4 Bytes=208)
    Statistics
    7 recursive calls
    0 db block gets
    21 consistent gets
    0 physical reads
    0 redo size
    701 bytes sent via SQL*Net to client
    507 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    8 rows processed
    But my questions are:
    1) In a where clause, if "<>" condition is used, then, whether the system will use the index. Because I have observed in several situations even though the column in where clause is indexed, since the where condition is "like" or "is null/is not null"
    then the index is not used. Same as like this, i assumed, if we use <> then indexes will not be used. Is it true?
    2) Now, after adding "o_id" and "o_no" columns to the index, the Execution plan is:
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=2 Card=8 Bytes=416)
    1 0 UNION-ALL
    2 1 INDEX (FULL SCAN) OF 'IDX_TEST_S_ID' (INDEX) (Cost=1 Card=4 Bytes=208)
    3 1 INDEX (FULL SCAN) OF 'IDX_TEST_S_ID' (INDEX) (Cost=1 Card=4 Bytes=208)
    Before it was :
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=6 Card=8 Bytes=416)
    1 0 UNION-ALL
    2 1 TABLE ACCESS (FULL) OF 'TEST_TABLE' (TABLE) (Cost=3 Card=4 Bytes=208)
    3 1 TABLE ACCESS (FULL) OF 'TEST_TABLE' (TABLE) (Cost=3 Card=4 Bytes=208)
    Difference only in Cost (reduced), not in Card, Bytes.
    Can you explain, how can i decide which makes the performace better (Cost / Card / Bytes). Full Scan / Range Scan?
    On statistics also:
    Before:
    Statistics
    52 recursive calls
    0 db block gets
    43 consistent gets
    0 physical reads
    0 redo size
    701 bytes sent via SQL*Net to client
    507 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    8 rows processed
    After:
    Statistics
    7 recursive calls
    0 db block gets
    21 consistent gets
    0 physical reads
    0 redo size
    701 bytes sent via SQL*Net to client
    507 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    8 rows processed
    Difference in recursive calls & consistent gets.
    Which one shows the query with better performance?
    Please explain..
    Regards
    Muthu

  • Using Index Vs dbms_stats.gather_table_stats

    Hello All,
    I would like to know in what situation would we benefit from using index and not analyse table as it takes time and in what situation analysing table is more beneficial then indexes.
    I have a task which creates 14 tables CATS, 2nd table is depended on 1st table for eg create table as t2 as select * from t1 so on and so forth. I am indexing all the 14 tables and gathering statistics.. my colleague says that if tables are indexed then gathering statistics is not required. So table1 - table14 need not have gather statistics. This module is used for large volume of data extract.
    My task is like
    1. create table t1 as select * from <table_name>
    create index
    gather_table_stats
    2. create table t2 as select * from t1
    create index
    gather_table_stats
    3. create table t3 as select * from t2
    create index
    gather_table_stats
    Regards,
    Rashida

    Rashida wrote:
    Hello All,
    I would like to know in what situation would we benefit from using index and not analyse table as it takes time and in what situation analysing table is more beneficial then indexes. You are comparing Apples and Oranges. They are different. They cant be compared.
    ANALYSE is done on a table to collect statistics of the table. CBO needs this information to get the best execution plan. INDEX is a data structure like your table. They help you in searching your data in your table in a faster way.
    For the optimizer to use your INDEX you need to have statistics of your TABLE and INDEX collected.
    I have a task which creates 14 tables CATS, 2nd table is depended on 1st table for eg create table as t2 as select * from t1 so on and so forth. I am indexing all the 14 tables and gathering statistics.. my colleague says that if tables are indexed then gathering statistics is not required. That is a totally wrong statement. This only means your colleague does not know about both INDEX and Statistics. And also how CBO works.

  • How do I stop Firefox from thinking it crashed and doing a recovery when forced to use Windows Task manager to close a bad URL that I never want to go back to?

    Long question, I know :~) There are web sites that I may visit that will not allow me to exit the site, so I use Alt-Ctrl-Del in Windows to start the Task Manager and force the site to close by ending the program. The new version of Firefox (31.0) thinks that Firefox crashed and send me right back to the source of my problem.
    Your documentation for this process is as follows:
    After a crash
    Due to unexpected issues such as problems with a website, software errors, or an accidental loss of power, Firefox may unexpectedly close. In these situations, Firefox can restore the pages that you were visiting when it is restarted. Firefox will automatically restore your previous session, the first time you launch it after a crash.
    If Firefox crashes a second time, the Restore Session (i.e. "Well, this is embarrassing") page will appear when you next launch Firefox.
    ...and this is what I found trying to stop this process. Next, when I am forced to use Task Manager to close Firefox a second time to stop a badware site, then the 'Well this is embarrassing' dialog appears and I am finally safely away from the URL.
    I do not want Firefox automatically sending me back to a problem site.
    Thank you for any procedure you can suggest to stop Firefox from restoring problem web pages, Art Clapton

    I am unwilling to attempt navigation away from these sites. The pop-ups that occur on the attempt to leave a site or to close the browser are exit traps offering incentive to stay.
    Once upon a time, when the internet was less dangerous, I would be willing to close the exit pop-ups. Now, after twice being infected with malware trying to close the pop-ups, I now force close whichever browser I am using.
    Recently, I clicked on the red X to close one pop-up, and it installed a trojan that I had to pay to be removed. When I clicked on 'Leave' in another exit pop, it didn't exit and it turned out I was giving permission to run a script file. Now that criminals have learned these exit pop-ups can be used to force a click action, the sites using them have become dangerous.
    If I force the browser to close using Task manager, Please tell me how to stop FireFox from sending me directly back to the same site because it mistakenly believes it crashed when it did not. I forced it to close because I was on a site that had taken control of my browser and was not allowing me to leave the site.
    No other browser sends me back to the potentially dangerous sites. I prefer Firefox, but the new version must have a setting that allows me to get safely away from a problem site?

  • How can i use index in select query.. facing problem with the select query.

    Hi Friends,
    I am facing a serious problem in one of the select query. It is taking a lot of time to fetch data in Production Scenario.
    Here is the query:
      SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
        FROM ztftelat LEFT JOIN ztfzberep
         ON  ztfzberep~gjahr = st_input-gjahr
         AND ztfzberep~poper = st_input-poper
         AND ztfzberepcntr  = ztftelatrprctr
        WHERE rldnr  = c_telstra_accounting
          AND rrcty  = c_actual
          AND rvers  = c_ver_001
          AND rbukrs = st_input-bukrs
          AND racct  = st_input-saknr
          AND ryear  = st_input-gjahr
          And rzzlstar in r_lstar                            
          AND rpmax  = c_max_period.
    There are 5 indices present for Table ZTFTELAT.
    Indices of ZTFTELAT:
      Name   Description                                               
      0        Primary key( RCLNT,RLDNR,RRCTY,RVERS,RYEAR,ROBJNR,SOBJNR,RTCUR,RUNIT,DRCRK,RPMAX)                                          
      005    Profit (RCLNT,RPRCTR)
      1        Ledger, company code, account (RLDNR,RBUKRS, RACCT)                                
      2        Ledger, company code, cost center (RLDNR, RBUKRS,RCNTR)                           
      3        Account, cost center (RACCT,RCNTR)                                        
      4        RCLNT/RLDNR/RRCTY/RVERS/RYEAR/RZZAUFNR                        
      Z01    Activity Type, Account (RZZLSTAR,RACCT)                                        
      Z02    RYEAR-RBUKRS- RZZZBER-RLDNR       
    Can anyone help me out why it is taking so much time and how we can reduce it ? and also tell me if I want to use index number 1 then how can I use?
    Thanks in advance.

    Hi Shiva,
    I am using two more select queries with the same manner ....
    here are the other two select query :
    ***************1************************
    SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
        FROM ztftelpt LEFT JOIN ztfzberep
         ON  ztfzberep~gjahr = st_input-gjahr
         AND ztfzberep~poper = st_input-poper
         AND ztfzberepcntr  = ztftelptrprctr
        WHERE rldnr  = c_telstra_projects
          AND rrcty  = c_actual
          AND rvers  = c_ver_001
          AND rbukrs = st_input-bukrs
          AND racct  = st_input-saknr
          AND ryear  = st_input-gjahr
          and rzzlstar in r_lstar             
          AND rpmax  = c_max_period.
    and the second one is
    *************************2************************
      SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
        FROM ztftelnt LEFT JOIN ztfzberep
         ON  ztfzberep~gjahr = st_input-gjahr
         AND ztfzberep~poper = st_input-poper
         AND ztfzberepcntr  = ztftelntrprctr
        WHERE rldnr  = c_telstra_networks
          AND rrcty  = c_actual
          AND rvers  = c_ver_001
          AND rbukrs = st_input-bukrs
          AND racct  = st_input-saknr
          AND ryear  = st_input-gjahr
          and rzzlstar in r_lstar                              
          AND rpmax  = c_max_period.
    for both the above table program is taking very less time .... although both the table used in above queries have similar amount of data. And i can not remove the APPENDING CORRESPONDING. because i have to append the data after fetching from the tables.  if i will not use it will delete all the data fetched earlier.
    Thanks on advanced......
    Sourabh

  • I have created my site with Muse and have uploaded to an external ftp hosting, now my secure log in will not work because I am not using BC. Is there a way to create a secure log in that will work with out being forced to use BC?

    I have created my site with Muse and have uploaded to an external ftp hosting, now my secure log in will not work because I am not using BC. Is there a way to create a secure log in that will work with out being forced to use BC?

    Hi
    Secure Zone login feature will only work if you host your website with Business catalyst.
    Please take a look to this as an alternative
    Password Protect Pages Widget for Adobe Muse
    Also, check this thread,
    Re: Can I create a login/password protection in Muse for a HTML5 page or two?

Maybe you are looking for

  • How to create a new rule in Windows Firewall to permit some specific IPs and block all other computers

    Hello, I have a Win7 PC. I want to block all incoming connections except 3 or 4 IPs. How can i do this? I created a new rule to block all connections using this steps: Inbound rules > New Rule > Custom > All Programs > All Protocols / Ports > All Loc

  • Iphoto and photoshop elements users question

    I elements installed so that it launches through iphoto when i have to edit a picture. I am familiar with elements from my prior windows machine (god forbid). Anyway, why does elements only show the frame on the mac? meaing the background is clear. I

  • Using javascript to change styles and such

    I want ot use javascript to change the "display" style of a div tag whatDiv.style.display = "block" This works fine if the div tag has an inline style defined: <div style="display:none"> ...</div> But if the tag has a class attached to it and the dis

  • Trackpad sensitivity since upgrade

    Ever since up upgraded to lion, my trackpad is ultra sensitive. I'll have my thumb hovering over the pad while scrolling around or circling on a page, and it will think i've tapped it. I've checked all my settings and can't find anywhere that changes

  • End of file error - avi exported from PPRO

    Encore 1.5 PPro 1.5 I have a project with 16 avi files exported from PPro. Four of them caused the error. I re-exported them and one was fixed. The other three keep causing the error. I am starting to get a little crazy trying to figure out what is g