SQL INDEX TUNING

Hi,
I am having a table with proper index. While selecting query, some time index is taken and some time table access full going on.
The table having following columns
Acc Id - Number
Account key = Number
Account Number - Varchar2(25)
Account Date - Date
Inst No - Number
Type Code - Varchar2(1).
Few more colums are there
The following indexes are there in the table
1. Acc ID - Primary Key
2. Account Key, trunc(account date) - Function based index
3. Account Key, type code - Normal Index
4. Inst No - Normal Index
Query
select * from ptable
where account_key = 128
and trunc(account_date) <= '30-apr-2008'
Trace is showing full table access and trace is given below.
recursive calls     78
db block gets     0
consistent gets     150
physical reads     0
redo size     0
bytes sent via SQL*Net to client     11577
bytes received via SQL*Net from client     671
SQL*Net roundtrips to/from client     2
sorts (memory)     1
sorts (disk)     0
If I change the date as '30-apr-0008', then the index is considered
recursive calls     78
db block gets     0
consistent gets     133
physical reads     0
redo size     0
bytes sent via SQL*Net to client     2525
bytes received via SQL*Net from client     671
SQL*Net roundtrips to/from client     2
sorts (memory)     1
sorts (disk)     0
Due to this my query is very slow. If i use the hint, index is considered.
What would be the reason for this. Whether I have to use always 'Hint'.
Oracle version - 10g R2

Hi,
Thanks for your information. I have already taken tkprof and analyze the query explain plan. I am not able to understand why it's reacting like. Here with I have enclosed explain plan and tkprof
Plan hash value: 1680079810
| Id | Operation           | Name                | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT      |                | 52789 | 11M | 669 (2) | 00:00:09 |
|* 1 | TABLE ACCESS FULL     | PS_TB_BRS_BANK_BOOK | 52789 | 11M | 669 (2) | 00:00:09 |
Predicate Information (identified by operation id):
1 - filter("BANK_ACCOUNT_KEY"=128 AND
TRUNC(INTERNAL_FUNCTION("VOUCHER_DATE"))<=TO_DATE('2008-04-30 00:00:00',
'yyyy-mm-dd hh24:mi:ss'))
Tkprof
Select Bank_Book_Id, Null Value_Date, Null Bank_Statement_Date, Voucher_Date,
Instrument_No "Key Column",Credit_Amount
From
Ps_Tb_Brs_Bank_Book Where Bank_Account_Key = 128 And Trunc(Voucher_Date) <=
'30-APR-08' And Brs_Match_Type_Code In ('U','P') And Instrument_No =
:G_Match And Instrument_No Is Not Null And Credit_Amount > 0
call count cpu elapsed disk query current rows
Parse 42140 0.70 0.83 0 0 0 0
Execute 42140 0.92 0.83 0 39 0 0
Fetch 45644 2046.39 1998.53 125604955 127350518 0 3504
total 129924 2048.03 2000.20 125604955 127350557 0 3504
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 38 (recursive depth: 1)
Rows Row Source Operation
0 TABLE ACCESS FULL PS_TB_BRS_BANK_BOOK (cr=3022 pr=2991 pw=0 time=51518 us)
Provide necessary guidelines to trace this.
Regards

Similar Messages

  • HOW TO: Post a SQL statement tuning request - template posting

    This post is not a question, but similar to Rob van Wijk's "When your query takes too long ..." post should help to improve the quality of the requests for SQL statement tuning here on OTN.
    On the OTN forum very often tuning requests about single SQL statements are posted, but the information provided is rather limited, and therefore it's not that simple to provide a meaningful advice. Instead of writing the same requests for additional information over and over again I thought I put together a post that describes how a "useful" post for such a request should look like and what information it should cover.
    I've also prepared very detailed step-by-step instructions how to obtain that information on my blog, which can be used to easily gather the required information. It also covers again the details how to post the information properly here, in particular how to use the \ tag to preserve formatting and get a fixed font output:
    http://oracle-randolf.blogspot.com/2009/02/basic-sql-statement-performance.html
    So again: This post here describes how a "useful" post should look like and what information it ideally covers. The blog post explains in detail how to obtain that information.
    In the future, rather than requesting the same additional information and explaining how to obtain it, I'll simply refer to this HOW TO post and the corresponding blog post which describes in detail how to get that information.
    *Very important:*
    Use the \ tag to enclose any output that should have its formatting preserved as shown below.
    So if you want to use fixed font formatting that preserves the spaces etc., do the following:
    \   This preserves formatting
    \And it will look like this:
       This preserves formatting
       . . .Your post should cover the following information:
    1. The SQL and a short description of its purpose
    2. The version of your database with 4-digits (e.g. 10.2.0.4)
    3. Optimizer related parameters
    4. The TIMING and AUTOTRACE output
    5. The EXPLAIN PLAN output
    6. The TKPROF output snippet that corresponds to your statement
    7. If you're on 10g or later, the DBMS_XPLAN.DISPLAY_CURSOR output
    The above mentioned blog post describes in detail how to obtain that information.
    Your post should have a meaningful subject, e.g. "SQL statement tuning request", and the message body should look similar to the following:
    *-- Start of template body --*
    The following SQL statement has been identified to perform poorly. It currently takes up to 10 seconds to execute, but it's supposed to take a second at most.
    This is the statement:
    select
    from
             t_demo
    where
             type = 'VIEW'
    order by
             id;It should return data from a table in a specific order.
    The version of the database is 11.1.0.7.
    These are the parameters relevant to the optimizer:
    SQL>
    SQL> show parameter optimizer
    NAME                                 TYPE        VALUE
    optimizer_capture_sql_plan_baselines boolean     FALSE
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      11.1.0.7
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      ALL_ROWS
    optimizer_secure_view_merging        boolean     TRUE
    optimizer_use_invisible_indexes      boolean     FALSE
    optimizer_use_pending_statistics     boolean     FALSE
    optimizer_use_sql_plan_baselines     boolean     TRUE
    SQL>
    SQL> show parameter db_file_multi
    NAME                                 TYPE        VALUE
    db_file_multiblock_read_count        integer     8
    SQL>
    SQL> show parameter db_block_size
    NAME                                 TYPE        VALUE
    db_block_size                        integer     8192
    SQL>
    SQL> show parameter cursor_sharing
    NAME                                 TYPE        VALUE
    cursor_sharing                       string      EXACT
    SQL>
    SQL> column sname format a20
    SQL> column pname format a20
    SQL> column pval2 format a20
    SQL>
    SQL> select
      2             sname
      3           , pname
      4           , pval1
      5           , pval2
      6  from
      7           sys.aux_stats$;
    SNAME                PNAME                     PVAL1 PVAL2
    SYSSTATS_INFO        STATUS                          COMPLETED
    SYSSTATS_INFO        DSTART                          01-30-2009 16:25
    SYSSTATS_INFO        DSTOP                           01-30-2009 16:25
    SYSSTATS_INFO        FLAGS                         0
    SYSSTATS_MAIN        CPUSPEEDNW              494,397
    SYSSTATS_MAIN        IOSEEKTIM                    10
    SYSSTATS_MAIN        IOTFRSPEED                 4096
    SYSSTATS_MAIN        SREADTIM
    SYSSTATS_MAIN        MREADTIM
    SYSSTATS_MAIN        CPUSPEED
    SYSSTATS_MAIN        MBRC
    SYSSTATS_MAIN        MAXTHR
    SYSSTATS_MAIN        SLAVETHR
    13 rows selected.Here is the output of EXPLAIN PLAN:
    SQL> explain plan for
      2  -- put your statement here
      3  select
      4             *
      5  from
      6             t_demo
      7  where
      8             type = 'VIEW'
      9  order by
    10             id;
    Explained.
    Elapsed: 00:00:00.01
    SQL>
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 1390505571
    | Id  | Operation                   | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |          |     1 |    60 |     0   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| T_DEMO   |     1 |    60 |     0   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | IDX_DEMO |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("TYPE"='VIEW')
    14 rows selected.Here is the output of SQL*Plus AUTOTRACE including the TIMING information:
    SQL> rem Set the ARRAYSIZE according to your application
    SQL> set autotrace traceonly arraysize 100
    SQL> select
      2             *
      3  from
      4             t_demo
      5  where
      6             type = 'VIEW'
      7  order by
      8             id;
    149938 rows selected.
    Elapsed: 00:00:02.21
    Execution Plan
    Plan hash value: 1390505571
    | Id  | Operation                   | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |          |     1 |    60 |     0   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| T_DEMO   |     1 |    60 |     0   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | IDX_DEMO |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("TYPE"='VIEW')
    Statistics
              0  recursive calls
              0  db block gets
         149101  consistent gets
            800  physical reads
            196  redo size
        1077830  bytes sent via SQL*Net to client
          16905  bytes received via SQL*Net from client
           1501  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
         149938  rows processed
    SQL>
    SQL> disconnect
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing optionsThe TKPROF output for this statement looks like the following:
    TKPROF: Release 11.1.0.7.0 - Production on Mo Feb 23 10:23:08 2009
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    Trace file: orcl11_ora_3376_mytrace1.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
    select
    from
             t_demo
    where
             type = 'VIEW'
    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     1501      0.53       1.36        800     149101          0      149938
    total     1503      0.53       1.36        800     149101          0      149938
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 88 
    Rows     Row Source Operation
    149938  TABLE ACCESS BY INDEX ROWID T_DEMO (cr=149101 pr=800 pw=0 time=60042 us cost=0 size=60 card=1)
    149938   INDEX RANGE SCAN IDX_DEMO (cr=1881 pr=1 pw=0 time=0 us cost=0 size=0 card=1)(object id 74895)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                    1501        0.00          0.00
      db file sequential read                       800        0.05          0.80
      SQL*Net message from client                  1501        0.00          0.69
    ********************************************************************************The DBMS_XPLAN.DISPLAY_CURSOR output:
    SQL> -- put your statement here
    SQL> -- use the GATHER_PLAN_STATISTICS hint
    SQL> -- if you're not using STATISTICS_LEVEL = ALL
    SQL> select /*+ gather_plan_statistics */
      2  *
      3  from
      4  t_demo
      5  where
      6  type = 'VIEW'
      7  order by
      8  id;
    149938 rows selected.
    Elapsed: 00:00:02.21
    SQL>
    SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
    PLAN_TABLE_OUTPUT
    SQL_ID  d4k5acu783vu8, child number 0
    select   /*+ gather_plan_statistics */          * from          t_demo
    where          type = 'VIEW' order by          id
    Plan hash value: 1390505571
    | Id  | Operation                   | Name     | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |
    |   0 | SELECT STATEMENT            |          |      1 |        |    149K|00:00:00.02 |     149K|   1183 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| T_DEMO   |      1 |      1 |    149K|00:00:00.02 |     149K|   1183 |
    |*  2 |   INDEX RANGE SCAN          | IDX_DEMO |      1 |      1 |    149K|00:00:00.02 |    1880 |    383 |
    Predicate Information (identified by operation id):
       2 - access("TYPE"='VIEW')
    20 rows selected.I'm looking forward for suggestions how to improve the performance of this statement.
    *-- End of template body --*
    I'm sure that if you follow these instructions and obtain the information described, post them using a proper formatting (don't forget about the \ tag) you'll receive meaningful advice very soon.
    So, just to make sure you didn't miss this point:Use proper formatting!
    If you think I missed something important in this sample post let me know so that I can improve it.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Alex Nuijten wrote:
    ...you missed the proper formatting of the Autotrace section ;-)Alex,
    can't reproduce, does it still look unformatted? Or are you simply kidding? :-)
    Randolf
    PS: Just noticed that it actually sometimes doesn't show the proper formatting although the code tags are there. Changing to the \ tag helped in this case, but it seems to be odd.
    Edited by: Randolf Geist on Feb 23, 2009 11:28 AM
    Odd behaviour of forum software                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Index Tuning Wizard in Enterprise Manager 10g Grid Control

    Hi,
    9i OEM has an Index Tuning Wizard. Does anyone know where is it located in 10g Enterprise Manager?
    Thanks!
    -Ranit.

    10g has an SQL Access Advisor (for tuning related to indexes and Materialized views) that is accessible via the OEM GC Advisor Central Link.
    Look to DB Targets - Select the DB - Select Advisor Central from the Related Links Section at the bottom - Select SQL Access Advisor.
    HTH,
    Tony

  • Launching Index Tuning Wizard from command prompt

    I have been playing with index tuning wizard and I could not figure how to launch it from command line (Manual says it can be launched via management console or oracle expert).
    DB2 and SQL Server provide executables which can be launched from command line. For example, below command evaluates given workload on target database and recommends something if necessary.
    Command> itw -d <targetDB> -w <workloadFile> -o <indexRecommendations>
    Is it possible to launch Oracle Index Tuning Wizard from command prompt in a similar way?
    -fa

    "TNS No Listener" => Start the listener
    To be connected as SYSDBA you dont need a password if your are logged in the DBA group, you just have to :
    PROD_:id
    uid=102(oracle) gid=103(oinstall)
    PROD_:sqlplus "/ as sysdba"
    SQL*Plus: Release 8.1.7.0.0 - Production on Wed Jul 23 11:46:50 2003
    (c) Copyright 2000 Oracle Corporation. All rights reserved.
    Connected to:
    Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
    With the Partitioning option
    JServer Release 8.1.7.4.0 - Production
    SQL> show user
    USER is "SYS"
    SQL>
    Fred

  • How to register PL/SQL index table parameter in OracleCallableStatement ?

    Hello ,
    I am using Oracle release 8.1.6.0.0 . I need to call a PL/SQL procedure through JDBC, which specifies an INDEX TABLE OUT parameter(e.g. TYPE type_name IS TABLE OF VARCHAR2(10) INDEX BY BINARY_INTEGER) .
    I found that with Oracle8i release 8.1.7, the Oracle JDBC OCI driver supports PL/SQL index-by tables using the registerIndexTableOutParameter method . But I have Oracle 8.1.6 and our client has 8.1.2!
    Is there any way that I can read INDEX TABLE PARAMETER from PL/SQL procedure with Oracle release 8.1.2 and 8.1.6?
    Another question is - Is it possible to do this with Oracle thin driver also ?
    Regards,
    Mukul

    i got the same problem? did you find the way to do it yet?
    thks a lot
    regards.

  • Index Tuning Wizard - Oracle 9i 9.2.0.1 (Linux)

    Hello,
    I recently installed Oracle 9i Release 2 on a Linux box (RH 8.0). I have been able to get everything working without any problems. I was interested in trying out the Index Tuning Wizard but I can seem to track down where it is on my installation. I downloaded the images from technet (3 cds) and re-checked my installation for the Tuning Pack but I don't see the Index Tuning Wizard from the OEM Console running on the Management Server.
    Under Tools/Tuning pack it lists only three tools (Outline Managment, ReOrg Wizard,and Tablespace Map). Anyway, I am stumped. I could have swore I used it on 8.1.7 in the past using Oracle Expert... Has it been removed? or is only available as a separate product now?
    Thanks in advance.
    Eric

    Well this is how I did it -- 3 short scripts:
    1) called 'oracle' placed in /etc/init.d with links to the
    appropriate runlevel -- say K03oracle and S95oracle.
    This script was:
    #!/bin/bash
    export ORACLE_HOME=/home/oracle/OraHome
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib
    export ORACLE_SID=quaoar
    PATH=$ORACLE_HOME/bin:$PATH
    export PATH
    if [ "$1" = 'start' ]
    then
    # the value should be around half your available memory
    sysctl -w kernel.shmmax=192000000
    su - oracle -c startOracle
    fi
    if [ "$1" = 'stop' ]
    then
    su - oracle -c stopOracle
    fi
    I then place the two scripts 'startOracle' and 'stopOracle'
    so that they are found in the PATH (i.e. say /usr/local/bin).
    This is so they can be later used to start and stop the
    database manually if needed.
    The 'startOracle' script was:
    #!/bin/bash
    sqlplus /nolog <<-HERE
    connect / as sysdba
    startup
    quit
    HERE
    lsnrctl start
    And the 'stopOracle' script was:
    #!/bin/bash
    sqlplus /nolog <<-HERE
    connect / as sysdba
    shutdown
    quit
    HERE
    lsnrctl stop
    This seemed to work just fine.
    Oracle has 'enhanced' sqlplus to do some of the
    old 'svrmgrl' tasks. Use the /nolog switch and
    'connect / as sysdba' while logged in as the main
    (install) Oracle user. This is the same as the
    old 'connect internal'.
    Harold

  • Sql query tuning

    How can i do SQl QUERY TUNING in Oracle 9i Database

    Hello,
    How can i do SQl QUERY TUNING in Oracle 9i Database You can start through reviewing the Performance Tuning Guide;
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96533/toc.htm
    Good Luck!
    Adith

  • SQL index of facttable disappears after full optimize + compress db

    Hello all,
    I have a customer that is using Outlooksoft 4.2sp3 for more then a year now. Every weekend a full optimize + compress database is running.
    Since 4 weeks, the SQL index of the fact table is disappeared after a full optimize+compress. They use a custom index and have about 95.000.000 records in the facttable.
    Does anyone have a clue why this index is deleted and perhaps a solution?
    Kind Regards,
    Alwin Berkhout
    Edited by: Alwin Berkhout on Apr 20, 2008 9:50 PM

    Joost, Sorin,
    I have created server extensions for the database that has these problems. Now for the first time since 5 weeks, after the optimize, the indexes are still there (or automatically recreated).
    Thanks for the tips.
    Strange thing though: why didn't I had this problem before?
    Alwin

  • How to download the ORACLE INDEX TUNING

    Hi,
    I am using Oracle 10g. i want to know how to download the ORACLE INDEX TUNING .
    Thank u...!

    Hi,
    Thank u for u r reply. I am asking about the Oracle Index tuning Wizard 9.2.0.1.0 Production. In the Oracle tuning book it has give this. That's why i am asking about the how to download the Oracle Index tuning Wizard 9.2.0.1.0 Production. Or where we will find this in oracle 10g.

  • Ebooks on SQL Query tuning

    HI.
    can somebody post me any links for ebooks on SQL Query tuning techniques for either 10g or 11g.
    Tuning SQL Queries is something I would like to build my expertise on..
    There may be a lot of advisors like SQL Query Advisor, Access Advisor and so on...but nothing like tuning your queries manually to maximum optimization.
    Kindly help me in this !!

    Check Oracle docs http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/toc.htm
    But you should really also be checking:
    http://www.asktom.oracle.com
    http://tkyte.blogspot.com
    AND all other blogs he referres to ( like Jonathan Lewis' site and blog ) you'll find many interesting articles over there, from 'the real world', regarding performance and tuning.
    Edited by: hoek on Mar 24, 2009 10:40 AM

  • Thin driver is not supported in PL/SQL Index-by Tables Sample Applications

    I have downloaded PL/SQL Index-by Tables Sample Application and running on JDeveloper 10g. It is giving me SQLExceprion Not supported. It works if I change the driver type to oci. Can anyone please help me how to run same application using thin.
    Thanks in advance
    Ratan

    Can you provide the info. for the Jdbc version and the database version that you are using? thanks.
    -cc

  • Complex SQL query Tuning

    Hi Fellas,
    I am new to query tuning. I have a big query with a TKPROF details. It is just fetching 34 records and taking approx 30 mins.
    The TKPROF detail will follow after the query.
    SELECT /*+ NO_INDEX(A, RA_CUSTOMER_TRX_N11 ) USE_NL(TYPES,A) */ a.customer_trx_id CUSTOMER_TRX_ID ,
    a.trx_number TRX_NUMBER ,
    A . INTERFACE_HEADER_ATTRIBUTE5 BILLING_STAGE ,
    A . INTERFACE_HEADER_CONTEXT PBRR_TYPE ,
    A . INTERFACE_HEADER_ATTRIBUTE11 BILLING_TERM ,
    NVL ( TL . SEQUENCE_NUM , 1 ) TERM_SEQUENCE_NUMBER ,
    types.type TRX_TYPE ,
    l_types.meaning TRX_TYPE_NAME ,
    TYPES . ACCOUNTING_AFFECT_FLAG OPEN_RECEIVABLE_FLAG ,
    a.trx_date TRX_DATE , SHIP_TO_CUSTOMER_ID SHIP_TO_CUSTOMER_ID ,
    SHIP_TO_CONTACT_ID SHIP_TO_CONTACT_ID ,
    REMIT_TO_ADDRESS_ID REMIT_TO_ADDRESS_ID ,
    A . PRIMARY_SALESREP_ID PRIMARY_SALESREP_ID ,
    B . ACCOUNT_NUMBER CUSTOMER_NUMBER ,
    A . INTERNAL_NOTES INTERNAL_NOTES ,
    A . COMMENTS TRX_COMMENTS ,
    PREVIOUS_CUSTOMER_TRX_ID PREVIOUS_CUSTOMER_TRX_ID ,
    SHIP_TO_SITE_USE_ID SHIP_TO_SITE_USE_ID ,
    NVL ( PRINTING_COUNT , 0 ) PRINTING_COUNT ,
    PRINTING_ORIGINAL_DATE PRINTING_ORIGINAL_DATE ,
    PRINTING_LAST_PRINTED PRINTING_LAST_PRINTED ,
    PRINTING_PENDING PRINTING_PENDING ,
    LAST_PRINTED_SEQUENCE_NUM LAST_PRINTED_SEQUENCE_NUMBER ,
    START_DATE_COMMITMENT START_DATE_COMMITMENT ,
    END_DATE_COMMITMENT END_DATE_COMMITMENT ,
    INITIAL_CUSTOMER_TRX_ID INITIAL_CUSTOMER_TRX_ID ,
    A . INVOICE_CURRENCY_CODE INVOICE_CURRENCY_CODE ,
    A . REASON_CODE CREDIT_HEADER_REASON_CODE_CSTM ,
    A . TERM_ID TERM_ID ,
    A . SHIP_DATE_ACTUAL SHIP_DATE_ACTUAL ,
    A . SHIP_VIA SHIP_VIA ,
    A . WAYBILL_NUMBER WAYBILL_NUMBER ,
    A . PURCHASE_ORDER PURCHASE_ORDER_NUMBER ,
    A . PURCHASE_ORDER_REVISION PURCHASE_ORDER_REVISION ,
    A . PURCHASE_ORDER_DATE PURCHASE_ORDER_DATE ,
    A . CREATED_BY ORDER_CREATED_BY_CSTM ,
    P . DUE_DATE TERM_DUE_DATE_FROM_PS ,
    NVL ( TL . RELATIVE_AMOUNT , 100 ) * ( 100 / NVL ( T . BASE_AMOUNT , 100 ) ) TERM_RELATIVE_AMOUNT ,
    T . NAME TERM_NAME ,
    A . BILL_TO_CUSTOMER_ID BILL_TO_CUSTOMER_ID ,
    A . BILL_TO_CONTACT_ID BILL_TO_CONTACT_ID ,
    A . BILL_TO_SITE_USE_ID BILL_TO_SITE_USE_ID ,
    U_BILL . LOCATION BILL_TO_LOCATION ,
    SUBSTRB ( PARTY . PARTY_NAME , 1 , 50 ) BILL_CUST_NAME ,
    RTRIM ( RPAD ( LOC . ADDRESS1 , 40 ) ) BILL_ADDRESS1 ,
    RTRIM ( RPAD ( LOC . ADDRESS2 , 40 ) ) BILL_ADDRESS2 ,
    RTRIM ( RPAD ( LOC . ADDRESS3 , 40 ) ) BILL_ADDRESS3 ,
    RTRIM ( RPAD ( LOC . ADDRESS4 , 40 ) ) BILL_ADDRESS4 ,
    LOC . CITY BILL_CITY , NVL ( LOC . STATE ,
    LOC . PROVINCE ) BILL_STATE ,
    LOC . POSTAL_CODE BILL_POSTAL_CODE ,
    LOC . COUNTRY BILL_COUNTRY ,
    U_BILL . TAX_REFERENCE BILL_SITE_TAX_REFERENCE ,
    PARTY . TAX_REFERENCE BILL_CUST_TAX_REFERENCE ,
    nvl(amount_line_items_original + decode(a.initial_customer_trx_id, '', 0, nvl(com_adj.amount,0)), to_number(null)) TRX_LINE_AMOUNT ,
    nvl(tax_original, to_number(null)) TRX_TAX_AMOUNT ,
    nvl(freight_original, to_number(null)) TRX_FREIGHT_AMOUNT ,
    p.amount_due_original + decode(a.initial_customer_trx_id, '', 0, nvl(com_adj.amount,0)) TRX_ALL_AMOUNT ,
    DECODE ( : P_ORDER_BY , 'TRX_NUMBER' , A . TRX_NUMBER , 'ADJUSTMENT_NUMBER' , A.TRX_NUMBER , 'CUSTOMER' , SUBSTRB ( PARTY . PARTY_NAME , 1 , 50 ) , 'POSTAL_CODE' , LOC . POSTAL_CODE , A . TRX_NUMBER ) ORDER_BY ,
    LOC . ADDRESS1 BILL_TO_ADDRESS1 ,
    LOC . ADDRESS2 BILL_TO_ADDRESS2 ,
    LOC . ADDRESS3 BILL_TO_ADDRESS3 ,
    LOC . ADDRESS4 BILL_TO_ADDRESS4 ,
    LOC . STATE BILL_TO_STATE ,
    LOC . PROVINCE BILL_TO_PROVINCE ,
    T . description Term_Description ,
    a . org_id ,
    a . created_from
    FROM
    AR_ADJUSTMENTS COM_ADJ,
    AR_PAYMENT_SCHEDULES P,
    RA_CUST_TRX_LINE_GL_DIST REC,
    RA_CUSTOMER_TRX A,
    HZ_CUST_ACCOUNTS B,
    RA_TERMS T,
    RA_TERMS_LINES TL,
    RA_CUST_TRX_TYPES TYPES,
    AR_LOOKUPS L_TYPES,
    HZ_PARTIES      PARTY,
    HZ_CUST_ACCT_SITES A_BILL,
    HZ_PARTY_SITES PARTY_SITE,
    HZ_LOCATIONS LOC,
    HZ_CUST_SITE_USES U_BILL
    WHERE
    A.BILL_TO_CUSTOMER_ID = B.CUST_ACCOUNT_ID AND
    REC.CUSTOMER_TRX_ID = A.CUSTOMER_TRX_ID AND
    REC.LATEST_REC_FLAG = 'Y' AND
    REC.ACCOUNT_CLASS = 'REC' AND
    P.PAYMENT_SCHEDULE_ID + DECODE ( P.CLASS , 'INV' , 0 , '' ) = COM_ADJ.PAYMENT_SCHEDULE_ID (+) AND
    COM_ADJ.SUBSEQUENT_TRX_ID IS NULL AND 'C' = COM_ADJ.ADJUSTMENT_TYPE (+) AND
    A.COMPLETE_FLAG = 'Y' AND
    A.CUST_TRX_TYPE_ID = TYPES.CUST_TRX_TYPE_ID AND
    L_TYPES.LOOKUP_TYPE = 'INV/CM/ADJ' AND
    A.PRINTING_OPTION IN ( 'PRI' , 'REP' ) AND
    L_TYPES.LOOKUP_CODE = DECODE ( TYPES.TYPE , 'DEP' , 'INV' , TYPES.TYPE ) AND
    NVL ( P.TERMS_SEQUENCE_NUMBER , nvl ( TL.SEQUENCE_NUM , 0 ) ) = nvl ( TL.SEQUENCE_NUM , nvl ( p.terms_sequence_number , 0 ) ) AND
    DECODE ( P.PAYMENT_SCHEDULE_ID , '' , 0 , NVL ( T.PRINTING_LEAD_DAYS , 0 ) ) = 0 AND
    A.BILL_TO_SITE_USE_ID = U_BILL.SITE_USE_ID AND
    U_BILL.CUST_ACCT_SITE_ID = A_BILL.CUST_ACCT_SITE_ID AND
    A_BILL.party_site_id = party_site.party_site_id AND
    B.PARTY_ID = PARTY.PARTY_ID AND
    loc.location_id = party_site.location_id AND
    NVL ( P.AMOUNT_DUE_REMAINING , 0 ) <> 0 AND
    A.CUST_TRX_TYPE_ID = 2526 AND
    TYPES.TYPE = 'INV' AND
    A.TERM_ID = TL.TERM_ID (+) AND
    A.TERM_ID = T.TERM_ID (+) AND
    A.CUSTOMER_TRX_ID = P.CUSTOMER_TRX_ID (+) AND
    A.PRINTING_PENDING = 'Y' AND
    NVL ( TL.SEQUENCE_NUM , 1 ) > NVL ( A.LAST_PRINTED_SEQUENCE_NUM , 0 ) and 1 = 1 AND
    NOT EXISTS ( SELECT 'X' from ECE_TP_DETAILS ETD ,
                        ECE_TP_HEADERS ETH
    WHERE
    ETH.TP_HEADER_ID = A_BILL.TP_HEADER_ID AND
    ETD.TP_HEADER_ID = ETH.TP_HEADER_ID AND
    ETD.EDI_FLAG = 'Y' AND
    ETD.DOCUMENT_ID = 'INO' AND
    ETD.DOCUMENT_TYPE = DECODE ( TYPES.TYPE , 'CM' , DECODE ( A.PREVIOUS_CUSTOMER_TRX_ID , NULL , 'OACM' , 'CM' ) , TYPES.TYPE ) ) AND
    A.PRINTING_OPTION IN ( 'PRI' , 'REP' ) AND
    T.NAME not like 'PB%' AND
    1 = 1 AND
    MIT_AR.GE_AR_COAKLEY_ELIGIBLE ( 'NEW' , P.CUSTOMER_TRX_ID , A.ORG_ID ) = 0 AND
    A.org_id = TYPES.org_id UNION SELECT /*+ NO_INDEX(A, RA_CUSTOMER_TRX_N11 ) USE_NL(TYPES,A) */
    a.customer_trx_id , a.trx_number ,
    A . INTERFACE_HEADER_ATTRIBUTE5 ,
    A . INTERFACE_HEADER_CONTEXT ,
    A . INTERFACE_HEADER_ATTRIBUTE11 ,
    NVL ( P . TERMS_SEQUENCE_NUMBER , 1 ) ,
    types.type , l_types.meaning ,
    TYPES . ACCOUNTING_AFFECT_FLAG ,
    a.trx_date ,
    A . SHIP_TO_CUSTOMER_ID ,
    A . SHIP_TO_CONTACT_ID ,
    A . REMIT_TO_ADDRESS_ID ,
    A . PRIMARY_SALESREP_ID ,
    B . ACCOUNT_NUMBER ,
    A . INTERNAL_NOTES ,
    A . COMMENTS ,
    PREVIOUS_CUSTOMER_TRX_ID ,
    SHIP_TO_SITE_USE_ID ,
    NVL ( PRINTING_COUNT , 0 ) ,
    PRINTING_ORIGINAL_DATE ,
    PRINTING_LAST_PRINTED ,
    PRINTING_PENDING ,
    LAST_PRINTED_SEQUENCE_NUM ,
    START_DATE_COMMITMENT ,
    END_DATE_COMMITMENT ,
    INITIAL_CUSTOMER_TRX_ID ,
    A . INVOICE_CURRENCY_CODE ,
    A . REASON_CODE ,
    A . TERM_ID ,
    A . SHIP_DATE_ACTUAL ,
    A . SHIP_VIA ,
    A . WAYBILL_NUMBER ,
    A . PURCHASE_ORDER ,
    A . PURCHASE_ORDER_REVISION ,
    A . PURCHASE_ORDER_DATE ,
    A . CREATED_BY ,
    P . DUE_DATE ,
    NVL ( TL . RELATIVE_AMOUNT , 100 ) * ( 100 / NVL ( T . BASE_AMOUNT , 100 ) ) ,
    T . NAME , A . BILL_TO_CUSTOMER_ID ,
    A . BILL_TO_CONTACT_ID ,
    A . BILL_TO_SITE_USE_ID ,
    U_BILL . LOCATION BILL_TO_LOCATION ,
    SUBSTRB ( PARTY . PARTY_NAME , 1 , 50 ) BILL_CUST_NAME ,
    RTRIM ( RPAD ( LOC . ADDRESS1 , 40 ) ) ,
    RTRIM ( RPAD ( LOC . ADDRESS2 , 40 ) ) ,
    RTRIM ( RPAD ( LOC . ADDRESS3 , 40 ) ) ,
    RTRIM ( RPAD ( LOC . ADDRESS4 , 40 ) ) ,
    LOC . CITY ,
    NVL ( LOC . STATE , LOC . PROVINCE ) ,
    LOC . POSTAL_CODE ,
    LOC . COUNTRY ,
    U_BILL . TAX_REFERENCE ,
    PARTY . TAX_REFERENCE ,
    nvl(amount_line_items_original + decode(a.initial_customer_trx_id, '', 0, nvl(com_adj.amount,0)), to_number(null)) ,
    nvl(tax_original, to_number(null)) ,
    nvl(freight_original, to_number(null)) ,
    p.amount_due_original + decode(a.initial_customer_trx_id, '', 0, nvl(com_adj.amount,0)) ,
    DECODE ( : P_ORDER_BY , 'TRX_NUMBER' ,
    A . TRX_NUMBER , 'ADJUSTMENT_NUMBER' ,
    A.TRX_NUMBER , 'CUSTOMER' ,
    SUBSTRB ( PARTY . PARTY_NAME , 1 , 50 ) , 'POSTAL_CODE' ,
    LOC . POSTAL_CODE , A . TRX_NUMBER ) ORDER_BY ,
    LOC . ADDRESS1 ,
    LOC . ADDRESS2 ,
    LOC . ADDRESS3 ,
    LOC . ADDRESS4 ,
    LOC . STATE ,
    LOC . PROVINCE ,
    T . description ,
    a . org_id ,
    a . created_from
    FROM
    RA_TERMS_LINES TL,
    RA_CUST_TRX_TYPES TYPES,
    AR_LOOKUPS L_TYPES,
         HZ_CUST_ACCOUNTS B,
    HZ_PARTIES      PARTY,
    HZ_CUST_SITE_USES U_BILL,
    HZ_CUST_ACCT_SITES A_BILL,
    HZ_PARTY_SITES PARTY_SITE,
    HZ_LOCATIONS LOC,
    AR_ADJUSTMENTS COM_ADJ,
    RA_CUSTOMER_TRX A,
    AR_PAYMENT_SCHEDULES P,
    RA_TERMS T
    WHERE
    A.BILL_TO_CUSTOMER_ID = B.CUST_ACCOUNT_ID
    AND P.PAYMENT_SCHEDULE_ID + DECODE ( P.CLASS , 'INV' , 0 , '' ) = COM_ADJ.PAYMENT_SCHEDULE_ID (+) AND
    COM_ADJ.SUBSEQUENT_TRX_ID IS NULL AND
    'C' = COM_ADJ.ADJUSTMENT_TYPE (+) AND
    A.COMPLETE_FLAG = 'Y' AND
    A.CUSTOMER_TRX_ID = P.CUSTOMER_TRX_ID AND
    A.CUST_TRX_TYPE_ID = TYPES.CUST_TRX_TYPE_ID AND
    L_TYPES.LOOKUP_TYPE = 'INV/CM/ADJ' AND
    A.PRINTING_OPTION IN ( 'PRI' , 'REP' ) AND
    L_TYPES.LOOKUP_CODE = DECODE ( TYPES.TYPE , 'DEP' , 'INV' , TYPES.TYPE ) AND
    NVL ( T.PRINTING_LEAD_DAYS , 0 ) > 0 AND
    A.BILL_TO_SITE_USE_ID = U_BILL.SITE_USE_ID AND
    U_BILL.CUST_ACCT_SITE_ID = A_BILL.CUST_ACCT_SITE_ID AND
    A_BILL.PARTY_SITE_ID = PARTY_SITE.PARTY_SITE_ID AND
    B.PARTY_ID = PARTY.PARTY_ID AND
    LOC.LOCATION_ID = PARTY_SITE.LOCATION_ID AND
    NVL ( P.TERMS_SEQUENCE_NUMBER , TL.SEQUENCE_NUM ) = TL.SEQUENCE_NUM AND
    NVL ( P.AMOUNT_DUE_REMAINING , 0 ) <> 0 AND
    A.CUST_TRX_TYPE_ID = 2526 AND
    TYPES.TYPE = 'INV' AND
    T.TERM_ID = P.TERM_ID AND
    TL.TERM_ID (+) = T.TERM_ID AND
    A.PRINTING_PENDING = 'Y' AND
    P.TERMS_SEQUENCE_NUMBER > NVL ( A.LAST_PRINTED_SEQUENCE_NUM , 0 ) and 1 = 1 AND
    NOT EXISTS ( SELECT 'X' from
    ECE_TP_DETAILS ETD ,
    ECE_TP_HEADERS ETH
    WHERE
    ETH.TP_HEADER_ID = A_BILL.TP_HEADER_ID AND
    ETD.TP_HEADER_ID = ETH.TP_HEADER_ID AND
    ETD.EDI_FLAG = 'Y' AND
    ETD.DOCUMENT_ID = 'INO' AND
    ETD.DOCUMENT_TYPE = DECODE ( TYPES.TYPE , 'CM' , DECODE ( A.PREVIOUS_CUSTOMER_TRX_ID , NULL , 'OACM' , 'CM' ) , TYPES.TYPE ) ) AND
    NVL ( A.PRINTING_OPTION , 'REP' ) IN ( 'PRI' , 'REP' ) AND
    T.NAME not like 'PB%' AND 1 = 1 AND
    MIT_AR.GE_AR_COAKLEY_ELIGIBLE ( 'NEW' , P.CUSTOMER_TRX_ID , A.ORG_ID ) = 0 AND
    A.org_id = TYPES.org_id
    ORDER BY 60 ASC,68 ASC,2 ASC,3 ASC,4 ASC,5 ASC,44 ASC
    call count cpu elapsed disk query current rows
    Parse 1 0.06 0.08 0 364 0 0
    Execute 1 5.11 4.98 0 0 0 0
    Fetch 18 81.35 1375.73 203636 357435 0 34
    total 20 86.52 1380.80 203636 357799 0 34
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 25
    Number of plan statistics captured: 1
    Rows (1st) Rows (avg) Rows (max) Row Source Operation
    34 34 34 SORT UNIQUE (cr=569992 pr=227554 pw=0 time=1658548772 us)
    34 34 34 UNION-ALL (cr=569992 pr=227554 pw=0 time=773822949 us)
    34 34 34 FILTER (cr=228022 pr=107808 pw=0 time=773820837 us)
    34 34 34 FILTER (cr=228022 pr=107808 pw=0 time=773820394 us)
    34 34 34 NESTED LOOPS OUTER (cr=228022 pr=107808 pw=0 time=771070499 us)
    34 34 34 NESTED LOOPS (cr=227986 pr=107806 pw=0 time=773799735 us)
    34 34 34 NESTED LOOPS (cr=227882 pr=107806 pw=0 time=773742298 us)
    34 34 34 NESTED LOOPS (cr=227812 pr=107806 pw=0 time=773688021 us)
    34 34 34 NESTED LOOPS (cr=227708 pr=107806 pw=0 time=773636699 us)
    34 34 34 FILTER (cr=227638 pr=107806 pw=0 time=773566978 us)
    4616 4616 4616 NESTED LOOPS OUTER (cr=220679 pr=106836 pw=0 time=823009777 us)
    4610 4610 4610 NESTED LOOPS (cr=206836 pr=102712 pw=0 time=623651066 us)
    4610 4610 4610 NESTED LOOPS (cr=188367 pr=96450 pw=0 time=531982352 us)
    4610 4610 4610 NESTED LOOPS (cr=179145 pr=96449 pw=0 time=530980660 us)
    4610 4610 4610 FILTER (cr=165290 pr=96448 pw=0 time=529149297 us)
    4610 4610 4610 NESTED LOOPS OUTER (cr=165290 pr=96448 pw=0 time=530066499 us)
    4607 4607 4607 NESTED LOOPS (cr=156074 pr=96442 pw=0 time=762671095 us)
    4615 4615 4615 NESTED LOOPS (cr=146842 pr=96441 pw=0 time=751255741 us)
    4615 4615 4615 NESTED LOOPS (cr=137610 pr=96435 pw=0 time=751144978 us)
    4615 4615 4615 NESTED LOOPS (cr=123763 pr=96435 pw=0 time=750949543 us)
    4615 4615 4615 TABLE ACCESS BY INDEX ROWID RA_CUSTOMER_TRX_ALL (cr=114531 pr=96435 pw=0 time=750675597 us)
    *329687 329687 329687 INDEX RANGE SCAN RA_CUSTOMER_TRX_N17 (cr=6232 pr=6046 pw=0 time=31982795 us)(object id 4788)* 4615 4615 4615 TABLE ACCESS BY INDEX ROWID RA_CUST_TRX_TYPES_ALL (cr=9232 pr=0 pw=0 time=239450 us)
    4615 4615 4615 INDEX UNIQUE SCAN RA_CUST_TRX_TYPES_U1 (cr=4617 pr=0 pw=0 time=160139 us)(object id 55731)
    4615 4615 4615 TABLE ACCESS BY INDEX ROWID FND_LOOKUP_VALUES (cr=13847 pr=0 pw=0 time=180337 us)
    4615 4615 4615 INDEX UNIQUE SCAN FND_LOOKUP_VALUES_U1 (cr=9232 pr=0 pw=0 time=135717 us)(object id 491822)
    4615 4615 4615 TABLE ACCESS BY INDEX ROWID RA_TERMS_B (cr=9232 pr=6 pw=0 time=155074 us)
    4615 4615 4615 INDEX UNIQUE SCAN RA_TERMS_B_U1 (cr=4617 pr=0 pw=0 time=60566 us)(object id 55734)
    4607 4607 4607 TABLE ACCESS BY INDEX ROWID RA_TERMS_TL (cr=9232 pr=1 pw=0 time=181115 us)
    4615 4615 4615 INDEX UNIQUE SCAN RA_TERMS_TL_U1 (cr=4617 pr=1 pw=0 time=82153 us)(object id 55755)
    4610 4610 4610 TABLE ACCESS BY INDEX ROWID RA_TERMS_LINES (cr=9216 pr=6 pw=0 time=259864 us)
    4610 4610 4610 INDEX RANGE SCAN RA_TERMS_LINES_U1 (cr=4609 pr=1 pw=0 time=104110 us)(object id 6703)
    4610 4610 4610 TABLE ACCESS BY INDEX ROWID HZ_CUST_SITE_USES_ALL (cr=13855 pr=1 pw=0 time=1350357 us)
    4610 4610 4610 INDEX UNIQUE SCAN HZ_CUST_SITE_USES_U1 (cr=9222 pr=1 pw=0 time=434079 us)(object id 44870)
    4610 4610 4610 TABLE ACCESS BY INDEX ROWID HZ_CUST_ACCT_SITES_ALL (cr=9222 pr=1 pw=0 time=1024466 us)
    4610 4610 4610 INDEX UNIQUE SCAN HZ_CUST_ACCT_SITES_U1 (cr=4612 pr=1 pw=0 time=337477 us)(object id 46883)
    4610 4610 4610 TABLE ACCESS BY INDEX ROWID RA_CUST_TRX_LINE_GL_DIST_ALL (cr=18469 pr=6262 pw=0 time=86754686 us)
    4610 4610 4610 INDEX RANGE SCAN RA_CUST_TRX_LINE_GL_DIST_N6 (cr=13836 pr=4061 pw=0 time=55844483 us)(object id 1510967)
    4616 4616 4616 TABLE ACCESS BY INDEX ROWID AR_PAYMENT_SCHEDULES_ALL (cr=13843 pr=4124 pw=0 time=50689789 us)
    4616 4616 4616 INDEX RANGE SCAN AR_PAYMENT_SCHEDULES_N2 (cr=9233 pr=1494 pw=0 time=15169412 us)(object id 4877)
    34 34 34 TABLE ACCESS BY INDEX ROWID HZ_CUST_ACCOUNTS (cr=70 pr=0 pw=0 time=24450 us)
    34 34 34 INDEX UNIQUE SCAN HZ_CUST_ACCOUNTS_U1 (cr=36 pr=0 pw=0 time=5962 us)(object id 85278)
    34 34 34 TABLE ACCESS BY INDEX ROWID HZ_PARTY_SITES (cr=104 pr=0 pw=0 time=58609 us)
    34 34 34 INDEX UNIQUE SCAN HZ_PARTY_SITES_U1 (cr=70 pr=0 pw=0 time=31189 us)(object id 45527)
    34 34 34 TABLE ACCESS BY INDEX ROWID HZ_LOCATIONS (cr=70 pr=0 pw=0 time=52502 us)
    34 34 34 INDEX UNIQUE SCAN HZ_LOCATIONS_U1 (cr=36 pr=0 pw=0 time=23883 us)(object id 45692)
    34 34 34 TABLE ACCESS BY INDEX ROWID HZ_PARTIES (cr=104 pr=0 pw=0 time=49042 us)
    34 34 34 INDEX UNIQUE SCAN HZ_PARTIES_U1 (cr=70 pr=0 pw=0 time=22106 us)(object id 757879)
    0 0 0 TABLE ACCESS BY INDEX ROWID AR_ADJUSTMENTS_ALL (cr=36 pr=2 pw=0 time=19638 us)
    0 0 0 INDEX RANGE SCAN AR_ADJUSTMENTS_N3 (cr=36 pr=2 pw=0 time=19271 us)(object id 5473)
    0 0 0 NESTED LOOPS (cr=0 pr=0 pw=0 time=9 us)
    0 0 0 INDEX UNIQUE SCAN ECE_TP_HEADERS_U1 (cr=0 pr=0 pw=0 time=7 us)(object id 46119)
    0 0 0 TABLE ACCESS BY INDEX ROWID ECE_TP_DETAILS (cr=0 pr=0 pw=0 time=0 us)
    0 0 0 INDEX UNIQUE SCAN ECE_TP_DETAILS_U2 (cr=0 pr=0 pw=0 time=0 us)(object id 6271)
    0 0 0 FILTER (cr=341970 pr=119746 pw=0 time=883424760 us)
    0 0 0 FILTER (cr=341970 pr=119746 pw=0 time=883424758 us)
    0 0 0 NESTED LOOPS OUTER (cr=341970 pr=119746 pw=0 time=883424757 us)
    0 0 0 NESTED LOOPS (cr=341970 pr=119746 pw=0 time=883424752 us)
    0 0 0 NESTED LOOPS (cr=341970 pr=119746 pw=0 time=883424749 us)
    0 0 0 NESTED LOOPS (cr=341970 pr=119746 pw=0 time=883424742 us)
    0 0 0 NESTED LOOPS (cr=341970 pr=119746 pw=0 time=883424740 us)
    0 0 0 NESTED LOOPS (cr=341970 pr=119746 pw=0 time=883424735 us)
    0 0 0 NESTED LOOPS (cr=341970 pr=119746 pw=0 time=883424731 us)
    0 0 0 NESTED LOOPS (cr=341970 pr=119746 pw=0 time=883424726 us)
    0 0 0 NESTED LOOPS (cr=341970 pr=119746 pw=0 time=883424724 us)
    0 0 0 NESTED LOOPS (cr=341970 pr=119746 pw=0 time=883424721 us)
    0 0 0 NESTED LOOPS (cr=341970 pr=119746 pw=0 time=883424715 us)
    34 34 34 NESTED LOOPS (cr=341900 pr=119746 pw=0 time=882400482 us)
    4615 4615 4615 NESTED LOOPS (cr=123763 pr=93484 pw=0 time=674293279 us)
    4615 4615 4615 TABLE ACCESS BY INDEX ROWID RA_CUSTOMER_TRX_ALL (cr=114531 pr=93484 pw=0 time=674030164 us)
    329687 329687 329687 INDEX RANGE SCAN RA_CUSTOMER_TRX_N17 (cr=6232 pr=6130 pw=0 time=36621510 us)(object id 4788)
    4615 4615 4615 TABLE ACCESS BY INDEX ROWID RA_CUST_TRX_TYPES_ALL (cr=9232 pr=0 pw=0 time=249893 us)
    4615 4615 4615 INDEX UNIQUE SCAN RA_CUST_TRX_TYPES_U1 (cr=4617 pr=0 pw=0 time=169485 us)(object id 55731)
    34 34 34 TABLE ACCESS BY INDEX ROWID AR_PAYMENT_SCHEDULES_ALL (cr=218137 pr=26262 pw=0 time=310068873 us)
    3304 3304 3304 INDEX RANGE SCAN AR_PAYMENT_SCHEDULES_N2 (cr=214841 pr=24355 pw=0 time=283359418 us)(object id 4877)
    0 0 0 TABLE ACCESS BY INDEX ROWID RA_TERMS_B (cr=70 pr=0 pw=0 time=829 us)
    34 34 34 INDEX UNIQUE SCAN RA_TERMS_B_U1 (cr=36 pr=0 pw=0 time=527 us)(object id 55734)
    0 0 0 TABLE ACCESS BY INDEX ROWID HZ_CUST_SITE_USES_ALL (cr=0 pr=0 pw=0 time=0 us)
    0 0 0 INDEX UNIQUE SCAN HZ_CUST_SITE_USES_U1 (cr=0 pr=0 pw=0 time=0 us)(object id 44870)
    0 0 0 TABLE ACCESS BY INDEX ROWID HZ_CUST_ACCT_SITES_ALL (cr=0 pr=0 pw=0 time=0 us)
    0 0 0 INDEX UNIQUE SCAN HZ_CUST_ACCT_SITES_U1 (cr=0 pr=0 pw=0 time=0 us)(object id 46883)
    0 0 0 TABLE ACCESS BY INDEX ROWID HZ_CUST_ACCOUNTS (cr=0 pr=0 pw=0 time=0 us)
    0 0 0 INDEX UNIQUE SCAN HZ_CUST_ACCOUNTS_U1 (cr=0 pr=0 pw=0 time=0 us)(object id 85278)
    0 0 0 TABLE ACCESS BY INDEX ROWID HZ_PARTIES (cr=0 pr=0 pw=0 time=0 us)
    0 0 0 INDEX UNIQUE SCAN HZ_PARTIES_U1 (cr=0 pr=0 pw=0 time=0 us)(object id 757879)
    0 0 0 TABLE ACCESS BY INDEX ROWID HZ_PARTY_SITES (cr=0 pr=0 pw=0 time=0 us)
    0 0 0 INDEX UNIQUE SCAN HZ_PARTY_SITES_U1 (cr=0 pr=0 pw=0 time=0 us)(object id 45527)
    0 0 0 TABLE ACCESS BY INDEX ROWID HZ_LOCATIONS (cr=0 pr=0 pw=0 time=0 us)
    0 0 0 INDEX UNIQUE SCAN HZ_LOCATIONS_U1 (cr=0 pr=0 pw=0 time=0 us)(object id 45692)
    0 0 0 TABLE ACCESS BY INDEX ROWID RA_TERMS_TL (cr=0 pr=0 pw=0 time=0 us)
    0 0 0 INDEX UNIQUE SCAN RA_TERMS_TL_U1 (cr=0 pr=0 pw=0 time=0 us)(object id 55755)
    0 0 0 TABLE ACCESS BY INDEX ROWID RA_TERMS_LINES (cr=0 pr=0 pw=0 time=0 us)
    0 0 0 INDEX RANGE SCAN RA_TERMS_LINES_U1 (cr=0 pr=0 pw=0 time=0 us)(object id 6703)
    0 0 0 TABLE ACCESS BY INDEX ROWID FND_LOOKUP_VALUES (cr=0 pr=0 pw=0 time=0 us)
    0 0 0 INDEX UNIQUE SCAN FND_LOOKUP_VALUES_U1 (cr=0 pr=0 pw=0 time=0 us)(object id 491822)
    0 0 0 TABLE ACCESS BY INDEX ROWID AR_ADJUSTMENTS_ALL (cr=0 pr=0 pw=0 time=0 us)
    0 0 0 INDEX RANGE SCAN AR_ADJUSTMENTS_N3 (cr=0 pr=0 pw=0 time=0 us)(object id 5473)
    0 0 0 NESTED LOOPS (cr=0 pr=0 pw=0 time=0 us)
    0 0 0 INDEX UNIQUE SCAN ECE_TP_HEADERS_U1 (cr=0 pr=0 pw=0 time=0 us)(object id 46119)
    0 0 0 TABLE ACCESS BY INDEX ROWID ECE_TP_DETAILS (cr=0 pr=0 pw=0 time=0 us)
    0 0 0 INDEX UNIQUE SCAN ECE_TP_DETAILS_U2 (cr=0 pr=0 pw=0 time=0 us)(object id 6271)
    Elapsed times include waiting on following events:
    Event waited on Times Max. Wait Total Waited
    ---------------------------------------- Waited ---------- ------------
    row cache lock 6 0.00 0.00
    SQL*Net message to client 18 0.00 0.00
    SQL*Net more data to client 2 0.00 0.00
    gc current block 2-way 5375 0.02 3.76
    gc cr grant 2-way 49175 0.05 24.09
    db file sequential read 203636 0.51 1289.70
    gcs drm freeze in enter server mode 7 0.28 1.30
    latch: KCL gc element parent latch 4 0.00 0.00
    gc remaster 2 0.07 0.12
    latch: gcs resource hash 26 0.00 0.00
    latch free 1 0.00 0.00
    gc cr block 2-way 9 0.00 0.00
    latch: cache buffers chains 1 0.00 0.00
    SQL*Net message from client 18 0.00 0.00
    Thanks in Advance..

    Hi,
    it looks like your problem stems from the wrong choice of the driving table:
    4615 4615 4615            NESTED LOOPS (cr=123763 pr=96435 pw=0 time=750949543 us)
    4615 4615 4615              TABLE ACCESS BY INDEX ROWID RA_CUSTOMER_TRX_ALL (cr=114531 pr=96435 pw=0 time=750675597 us)
    329687 329687 329687       INDEX RANGE SCAN RA_CUSTOMER_TRX_N17 (cr=6232 pr=6046 pw=0 time=31982795 us)(object id 4788) 4615 4615 4615 TABLE ACCESS BY INDEX ROWID RA_CUST_TRX_TYPES_ALL (cr=9232 pr=0 pw=0 time=239450 us)
    4615 4615 4615              INDEX UNIQUE SCAN RA_CUST_TRX_TYPES_U1 (cr=4617 pr=0 pw=0 time=160139 us)(object id 55731)
    4615 4615 4615              TABLE ACCESS BY INDEX ROWID FND_LOOKUP_VALUES (cr=13847 pr=0 pw=0 time=180337 us)Here, you are spending 750 seconds retriveing 329k rows, 98% of which are rejected on the next step. And the reason this is happening is because the optimizer underestimates the cardinatlity of this step by a factor of x50 (6.2k estimated, 329k actual value). Find out why this is happening or post relevant diagnostic information here (predicates, columns stats etc.), and fix this -- this should make your query twice as fast.
    The second half is coming from the SORT UNIQUE step. This looks weird: why on Earth it would take over 800 seconds to sort 34 rows?! Maybe there is something in the plan that I'm missing -- it's really hard to read because it's not formatted. Please obtain a plan with rowsource stats using dbms_xplan.display_cursor and post it here (google dbms_xplan.display_cursor allstats last if not sure how to do that).
    Best regards,
    Nikolay

  • Sql Query Tuning. Please help me to tune this query

    Hi All ,
    I have this problematic Sql . It is taking huge time to execute. It contains a view CIDV, which i think is the bottleneck.
    I have pasted the query below. I will be pasting TKPROF and explain plan for the same. Please advice me to tune this query.
    SELECT GCC.SEGMENT1 || '.' || GCC.SEGMENT2 || '.' || GCC.SEGMENT3 || '.' ||
           GCC.SEGMENT4 || '.' || GCC.SEGMENT5 || '.' || GCC.SEGMENT6 || '.' ||
           GCC.SEGMENT7 || '.' || GCC.SEGMENT8 || '.' || GCC.SEGMENT9 OFFSET_ACCOUNT,
           OOD.ORGANIZATION_CODE,
           CIDV.SUBINVENTORY_CODE OFFSET_SUBINV,
           MIL.SEGMENT1 || '.' || MIL.SEGMENT2 || '.' || MIL.SEGMENT3 || '.' ||
           MIL.SEGMENT4 || '.' || MIL.SEGMENT5 OFFSET_LOCATOR,
           CIDV.LAST_UPDATE_LOGIN
      FROM APPS.CST_INV_DISTRIBUTION_V       CIDV,
           APPS.GL_CODE_COMBINATIONS         GCC,
           APPS.MTL_ITEM_LOCATIONS           MIL,
           APPS.ORG_ORGANIZATION_DEFINITIONS OOD
    WHERE CIDV.TRANSACTION_ID = :B2
       AND CIDV.PRIMARY_QUANTITY = (-1) * :B1
       AND CIDV.REFERENCE_ACCOUNT = GCC.CODE_COMBINATION_ID
       AND OOD.ORGANIZATION_ID = CIDV.ORGANIZATION_ID
       AND MIL.INVENTORY_LOCATION_ID = CIDV.LOCATOR_ID
       AND GCC.ACCOUNT_TYPE = 'A'****************
    TKPROF
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute  68337     10.32      10.32          0          0          0           0
    Fetch    68337    229.75     936.36      58819    6743323       1121       68232
    total   136675    240.07     946.69      58819    6743323       1121       68232
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 203     (recursive depth: 1)
    Number of plan statistics captured: 1
    Rows (1st) Rows (avg) Rows (max)  Row Source Operation
             1          1          1  MERGE JOIN CARTESIAN (cr=102 pr=15 pw=0 time=193608 us cost=56 size=219 card=1)
             1          1          1   NESTED LOOPS  (cr=100 pr=15 pw=0 time=193483 us cost=53 size=219 card=1)
             1          1          1    NESTED LOOPS  (cr=99 pr=15 pw=0 time=193407 us cost=52 size=215 card=1)
             1          1          1     NESTED LOOPS  (cr=96 pr=15 pw=0 time=193378 us cost=51 size=190 card=1)
             1          1          1      NESTED LOOPS  (cr=93 pr=15 pw=0 time=193284 us cost=49 size=162 card=1)
             1          1          1       NESTED LOOPS  (cr=89 pr=14 pw=0 time=185515 us cost=46 size=138 card=1)
             1          1          1        NESTED LOOPS  (cr=85 pr=12 pw=0 time=157975 us cost=44 size=81 card=1)
             1          1          1         NESTED LOOPS  (cr=83 pr=12 pw=0 time=157925 us cost=43 size=73 card=1)
             1          1          1          NESTED LOOPS  (cr=81 pr=12 pw=0 time=157641 us cost=43 size=132 card=2)
             1          1          1           VIEW  CST_INV_DISTRIBUTION_V (cr=78 pr=12 pw=0 time=156386 us cost=41 size=118 card=2)
             1          1          1            UNION-ALL  (cr=78 pr=12 pw=0 time=156378 us)
             0          0          0             NESTED LOOPS OUTER (cr=44 pr=9 pw=0 time=124997 us cost=20 size=291 card=1)
             0          0          0              NESTED LOOPS  (cr=44 pr=9 pw=0 time=124993 us cost=18 size=255 card=1)
             0          0          0               NESTED LOOPS  (cr=44 pr=9 pw=0 time=124990 us cost=18 size=251 card=1)
            33         33         33                MERGE JOIN CARTESIAN (cr=25 pr=6 pw=0 time=98544 us cost=14 size=192 card=1)
             1          1          1                 NESTED LOOPS OUTER (cr=22 pr=5 pw=0 time=85754 us cost=12 size=156 card=1)
             1          1          1                  NESTED LOOPS  (cr=19 pr=4 pw=0 time=79830 us cost=10 size=120 card=1)
             1          1          1                   NESTED LOOPS OUTER (cr=17 pr=4 pw=0 time=79813 us cost=9 size=113 card=1)
             1          1          1                    NESTED LOOPS  (cr=15 pr=4 pw=0 time=79752 us cost=8 size=106 card=1)
             1          1          1                     NESTED LOOPS  (cr=11 pr=2 pw=0 time=43120 us cost=6 size=93 card=1)
             1          1          1                      NESTED LOOPS  (cr=7 pr=2 pw=0 time=43087 us cost=4 size=83 card=1)
             1          1          1                       NESTED LOOPS  (cr=6 pr=2 pw=0 time=43072 us cost=4 size=80 card=1)
             1          1          1                        TABLE ACCESS BY INDEX ROWID MTL_MATERIAL_TRANSACTIONS (cr=5 pr=2 pw=0 time=43042 us cost=4 size=76 card=1)
             1          1          1                         INDEX UNIQUE SCAN MTL_MATERIAL_TRANSACTIONS_U1 (cr=4 pr=2 pw=0 time=43011 us cost=3 size=0 card=1)(object id 12484094)
             1          1          1                        INDEX UNIQUE SCAN MTL_TRANSACTION_TYPES_U1 (cr=1 pr=0 pw=0 time=20 us cost=0 size=764 card=191)(object id 9983)
             1          1          1                       INDEX UNIQUE SCAN MTL_TXN_SOURCE_TYPES_U1 (cr=1 pr=0 pw=0 time=7 us cost=0 size=54 card=18)(object id 9987)
             1          1          1                      INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=4 pr=0 pw=0 time=27 us cost=2 size=736324450 card=73632445)(object id 12484155)
             1          1          1                     INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_TL_U1 (cr=4 pr=2 pw=0 time=36626 us cost=2 size=957481070 card=73652390)(object id 12484137)
             1          1          1                    TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 pr=0 pw=0 time=42 us cost=1 size=3290 card=470)
             1          1          1                     INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 pr=0 pw=0 time=28 us cost=0 size=0 card=1)(object id 9847)
             1          1          1                   TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 pr=0 pw=0 time=12 us cost=1 size=3290 card=470)
             1          1          1                    INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 pr=0 pw=0 time=7 us cost=0 size=0 card=1)(object id 9847)
             0          0          0                  INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=3 pr=1 pw=0 time=5915 us cost=2 size=36 card=1)(object id 705891)
            33         33         33                 BUFFER SORT (cr=3 pr=1 pw=0 time=12713 us cost=12 size=36 card=1)
            33         33         33                  INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=3 pr=1 pw=0 time=12582 us cost=2 size=36 card=1)(object id 705891)
             0          0          0                TABLE ACCESS BY INDEX ROWID MTL_TRANSACTION_ACCOUNTS (cr=19 pr=3 pw=0 time=26591 us cost=4 size=59 card=1)
            66         66         66                 INDEX RANGE SCAN MTL_TRANSACTION_ACCOUNTS_N1 (cr=18 pr=2 pw=0 time=13607 us cost=3 size=0 card=3)(object id 12484127)
             0          0          0               INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=0 pr=0 pw=0 time=0 us cost=0 size=4 card=1)(object id 9847)
             0          0          0              INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=0 pr=0 pw=0 time=0 us cost=2 size=36 card=1)(object id 705891)
             1          1          1             NESTED LOOPS  (cr=34 pr=3 pw=0 time=31269 us cost=21 size=288 card=1)
             1          1          1              NESTED LOOPS  (cr=30 pr=3 pw=0 time=31161 us cost=19 size=275 card=1)
             1          1          1               NESTED LOOPS  (cr=26 pr=3 pw=0 time=31105 us cost=17 size=265 card=1)
             1          1          1                NESTED LOOPS  (cr=25 pr=3 pw=0 time=31082 us cost=17 size=261 card=1)
             1          1          1                 NESTED LOOPS OUTER (cr=23 pr=3 pw=0 time=31027 us cost=16 size=254 card=1)
             1          1          1                  NESTED LOOPS  (cr=21 pr=3 pw=0 time=30980 us cost=15 size=247 card=1)
             1          1          1                   NESTED LOOPS  (cr=20 pr=3 pw=0 time=30957 us cost=15 size=243 card=1)
             1          1          1                    NESTED LOOPS OUTER (cr=19 pr=3 pw=0 time=30926 us cost=15 size=240 card=1)
             1          1          1                     NESTED LOOPS  (cr=16 pr=3 pw=0 time=30389 us cost=13 size=204 card=1)
             1          1          1                      NESTED LOOPS  (cr=11 pr=0 pw=0 time=665 us cost=9 size=131 card=1)
             1          1          1                       NESTED LOOPS OUTER (cr=8 pr=0 pw=0 time=306 us cost=7 size=95 card=1)
             1          1          1                        TABLE ACCESS BY INDEX ROWID MTL_TRANSACTION_ACCOUNTS (cr=5 pr=0 pw=0 time=37 us cost=5 size=59 card=1)
             2          2          2                         INDEX RANGE SCAN MTL_TRANSACTION_ACCOUNTS_N1 (cr=4 pr=0 pw=0 time=17 us cost=4 size=0 card=3)(object id 12484127)
             1          1          1                        INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=3 pr=0 pw=0 time=216 us cost=2 size=36 card=1)(object id 705891)
             1          1          1                       INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=3 pr=0 pw=0 time=352 us cost=2 size=36 card=1)(object id 705891)
             1          1          1                      TABLE ACCESS BY INDEX ROWID MTL_MATERIAL_TRANSACTIONS (cr=5 pr=3 pw=0 time=29716 us cost=4 size=73 card=1)
             1          1          1                       INDEX RANGE SCAN MTL_MATERIAL_TRANSACTIONS_N23 (cr=4 pr=3 pw=0 time=29588 us cost=3 size=0 card=1)(object id 12484133)
             0          0          0                     INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=3 pr=0 pw=0 time=520 us cost=2 size=36 card=1)(object id 705891)
             1          1          1                    INDEX UNIQUE SCAN MTL_TXN_SOURCE_TYPES_U1 (cr=1 pr=0 pw=0 time=22 us cost=0 size=3 card=1)(object id 9987)
             1          1          1                   INDEX UNIQUE SCAN MTL_TRANSACTION_TYPES_U1 (cr=1 pr=0 pw=0 time=16 us cost=0 size=4 card=1)(object id 9983)
             1          1          1                  TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 pr=0 pw=0 time=34 us cost=1 size=7 card=1)
             1          1          1                   INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 pr=0 pw=0 time=19 us cost=0 size=0 card=1)(object id 9847)
             1          1          1                 TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 pr=0 pw=0 time=44 us cost=1 size=7 card=1)
             1          1          1                  INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 pr=0 pw=0 time=14 us cost=0 size=0 card=1)(object id 9847)
             1          1          1                INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 pr=0 pw=0 time=13 us cost=0 size=4 card=1)(object id 9847)
             1          1          1               INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=4 pr=0 pw=0 time=49 us cost=2 size=10 card=1)(object id 12484155)
             1          1          1              INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_TL_U1 (cr=4 pr=0 pw=0 time=96 us cost=2 size=13 card=1)(object id 12484137)
             1          1          1           TABLE ACCESS BY INDEX ROWID HR_ALL_ORGANIZATION_UNITS (cr=3 pr=0 pw=0 time=1246 us cost=1 size=7 card=1)
             1          1          1            INDEX UNIQUE SCAN HR_ORGANIZATION_UNITS_PK (cr=2 pr=0 pw=0 time=24 us cost=0 size=0 card=1)(object id 250158)
             1          1          1          INDEX UNIQUE SCAN HR_ALL_ORGANIZATION_UNTS_TL_PK (cr=2 pr=0 pw=0 time=275 us cost=0 size=7 card=1)(object id 689101)
             1          1          1         TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 pr=0 pw=0 time=38 us cost=1 size=8 card=1)
             1          1          1          INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 pr=0 pw=0 time=15 us cost=0 size=0 card=1)(object id 9847)
             1          1          1        TABLE ACCESS BY INDEX ROWID GL_CODE_COMBINATIONS (cr=4 pr=2 pw=0 time=27531 us cost=2 size=57 card=1)
             1          1          1         INDEX UNIQUE SCAN GL_CODE_COMBINATIONS_U1 (cr=3 pr=1 pw=0 time=19925 us cost=1 size=0 card=1)(object id 51426)
             1          1          1       TABLE ACCESS BY INDEX ROWID MTL_ITEM_LOCATIONS (cr=4 pr=1 pw=0 time=7758 us cost=3 size=24 card=1)
             1          1          1        INDEX RANGE SCAN MTL_ITEM_LOCATIONS_U1 (cr=3 pr=0 pw=0 time=51 us cost=2 size=0 card=1)(object id 9761)
             1          1          1      TABLE ACCESS BY INDEX ROWID HR_ORGANIZATION_INFORMATION (cr=3 pr=0 pw=0 time=85 us cost=2 size=28 card=1)
             1          1          1       INDEX RANGE SCAN HR_ORGANIZATION_INFORMATIO_FK2 (cr=2 pr=0 pw=0 time=29 us cost=1 size=0 card=2)(object id 5379798)
             1          1          1     TABLE ACCESS BY INDEX ROWID HR_ORGANIZATION_INFORMATION (cr=3 pr=0 pw=0 time=25 us cost=1 size=25 card=1)
             1          1          1      INDEX RANGE SCAN HR_ORGANIZATION_INFORMATIO_FK2 (cr=2 pr=0 pw=0 time=11 us cost=1 size=0 card=1)(object id 5379798)
             1          1          1    INDEX FULL SCAN GL_SETS_OF_BOOKS_U2 (cr=1 pr=0 pw=0 time=69 us cost=1 size=4 card=1)(object id 1380842)
             1          1          1   BUFFER SORT (cr=2 pr=0 pw=0 time=110 us cost=55 size=0 card=1)
             1          1          1    TABLE ACCESS FULL FND_PRODUCT_GROUPS (cr=2 pr=0 pw=0 time=59 us cost=3 size=0 card=1)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      library cache lock                              2        0.00          0.00
      library cache pin                               2        0.00          0.00
      Disk file operations I/O                      249        0.00          0.00
      db file sequential read                     58819        2.61        714.28
      gc cr grant 2-way                            5198        0.16          4.52
      gc current grant busy                           1        0.00          0.00
      KJC: Wait for msg sends to complete           517        0.00          0.05
      library cache: mutex X                        433        0.01          0.04
      gc cr grant congested                          28        0.08          0.18
      latch: ges resource hash list                   5        0.00          0.00
      gc current block 2-way                        513        0.11          0.61
      gc current block congested                      2        0.00          0.00
      latch: gc element                              16        0.00          0.01
      latch: cache buffers chains                     4        0.00          0.00
      latch: object queue header operation            3        0.00          0.00
    ********************************************************************************

    Explain Plan for the query
    SELECT STATEMENT, GOAL = ALL_ROWS               Cost=56     Cardinality=1     Bytes=219
    MERGE JOIN CARTESIAN               Cost=56     Cardinality=1     Bytes=219
      NESTED LOOPS               Cost=53     Cardinality=1     Bytes=219
       NESTED LOOPS               Cost=52     Cardinality=1     Bytes=215
        NESTED LOOPS               Cost=51     Cardinality=1     Bytes=190
         NESTED LOOPS               Cost=49     Cardinality=1     Bytes=162
          NESTED LOOPS               Cost=46     Cardinality=1     Bytes=138
           NESTED LOOPS               Cost=44     Cardinality=1     Bytes=81
            NESTED LOOPS               Cost=43     Cardinality=1     Bytes=73
             NESTED LOOPS               Cost=43     Cardinality=2     Bytes=132
              VIEW     Object owner=APPS     Object name=CST_INV_DISTRIBUTION_V     Cost=41     Cardinality=2     Bytes=118
               UNION-ALL                         
                NESTED LOOPS OUTER               Cost=20     Cardinality=1     Bytes=291
                 NESTED LOOPS               Cost=18     Cardinality=1     Bytes=255
                  NESTED LOOPS               Cost=18     Cardinality=1     Bytes=251
                   MERGE JOIN CARTESIAN               Cost=14     Cardinality=1     Bytes=192
                    NESTED LOOPS OUTER               Cost=12     Cardinality=1     Bytes=156
                     NESTED LOOPS               Cost=10     Cardinality=1     Bytes=120
                      NESTED LOOPS OUTER               Cost=9     Cardinality=1     Bytes=113
                       NESTED LOOPS               Cost=8     Cardinality=1     Bytes=106
                        NESTED LOOPS               Cost=6     Cardinality=1     Bytes=93
                         NESTED LOOPS               Cost=4     Cardinality=1     Bytes=83
                          NESTED LOOPS               Cost=4     Cardinality=1     Bytes=80
                           TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_MATERIAL_TRANSACTIONS     Cost=4     Cardinality=1     Bytes=76
                            INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_MATERIAL_TRANSACTIONS_U1     Cost=3     Cardinality=1     
                           INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_TRANSACTION_TYPES_U1     Cost=0     Cardinality=191     Bytes=764
                          INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_TXN_SOURCE_TYPES_U1     Cost=0     Cardinality=18     Bytes=54
                         INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_SYSTEM_ITEMS_B_U1     Cost=2     Cardinality=73632445     Bytes=736324450
                        INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_SYSTEM_ITEMS_TL_U1     Cost=2     Cardinality=73652390     Bytes=957481070
                       TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_PARAMETERS     Cost=1     Cardinality=470     Bytes=3290
                        INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     
                      TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_PARAMETERS     Cost=1     Cardinality=470     Bytes=3290
                       INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     
                     INDEX RANGE SCAN     Object owner=APPLSYS     Object name=FND_LOOKUP_VALUES_U1     Cost=2     Cardinality=1     Bytes=36
                    BUFFER SORT               Cost=12     Cardinality=1     Bytes=36
                     INDEX RANGE SCAN     Object owner=APPLSYS     Object name=FND_LOOKUP_VALUES_U1     Cost=2     Cardinality=1     Bytes=36
                   TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_TRANSACTION_ACCOUNTS     Cost=4     Cardinality=1     Bytes=59
                    INDEX RANGE SCAN     Object owner=INV     Object name=MTL_TRANSACTION_ACCOUNTS_N1     Cost=3     Cardinality=3     
                  INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     Bytes=4
                 INDEX RANGE SCAN     Object owner=APPLSYS     Object name=FND_LOOKUP_VALUES_U1     Cost=2     Cardinality=1     Bytes=36
                NESTED LOOPS               Cost=21     Cardinality=1     Bytes=288
                 NESTED LOOPS               Cost=19     Cardinality=1     Bytes=275
                  NESTED LOOPS               Cost=17     Cardinality=1     Bytes=265
                   NESTED LOOPS               Cost=17     Cardinality=1     Bytes=261
                    NESTED LOOPS OUTER               Cost=16     Cardinality=1     Bytes=254
                     NESTED LOOPS               Cost=15     Cardinality=1     Bytes=247
                      NESTED LOOPS               Cost=15     Cardinality=1     Bytes=243
                       NESTED LOOPS OUTER               Cost=15     Cardinality=1     Bytes=240
                        NESTED LOOPS               Cost=13     Cardinality=1     Bytes=204
                         NESTED LOOPS               Cost=9     Cardinality=1     Bytes=131
                          NESTED LOOPS OUTER               Cost=7     Cardinality=1     Bytes=95
                           TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_TRANSACTION_ACCOUNTS     Cost=5     Cardinality=1     Bytes=59
                            INDEX RANGE SCAN     Object owner=INV     Object name=MTL_TRANSACTION_ACCOUNTS_N1     Cost=4     Cardinality=3     
                           INDEX RANGE SCAN     Object owner=APPLSYS     Object name=FND_LOOKUP_VALUES_U1     Cost=2     Cardinality=1     Bytes=36
                          INDEX RANGE SCAN     Object owner=APPLSYS     Object name=FND_LOOKUP_VALUES_U1     Cost=2     Cardinality=1     Bytes=36
                         TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_MATERIAL_TRANSACTIONS     Cost=4     Cardinality=1     Bytes=73
                          INDEX RANGE SCAN     Object owner=INV     Object name=MTL_MATERIAL_TRANSACTIONS_N23     Cost=3     Cardinality=1     
                        INDEX RANGE SCAN     Object owner=APPLSYS     Object name=FND_LOOKUP_VALUES_U1     Cost=2     Cardinality=1     Bytes=36
                       INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_TXN_SOURCE_TYPES_U1     Cost=0     Cardinality=1     Bytes=3
                      INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_TRANSACTION_TYPES_U1     Cost=0     Cardinality=1     Bytes=4
                     TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_PARAMETERS     Cost=1     Cardinality=1     Bytes=7
                      INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     
                    TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_PARAMETERS     Cost=1     Cardinality=1     Bytes=7
                     INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     
                   INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     Bytes=4
                  INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_SYSTEM_ITEMS_B_U1     Cost=2     Cardinality=1     Bytes=10
                 INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_SYSTEM_ITEMS_TL_U1     Cost=2     Cardinality=1     Bytes=13
              TABLE ACCESS BY INDEX ROWID     Object owner=HR     Object name=HR_ALL_ORGANIZATION_UNITS     Cost=1     Cardinality=1     Bytes=7
               INDEX UNIQUE SCAN     Object owner=HR     Object name=HR_ORGANIZATION_UNITS_PK     Cost=0     Cardinality=1     
             INDEX UNIQUE SCAN     Object owner=HR     Object name=HR_ALL_ORGANIZATION_UNTS_TL_PK     Cost=0     Cardinality=1     Bytes=7
            TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_PARAMETERS     Cost=1     Cardinality=1     Bytes=8
             INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     
           TABLE ACCESS BY INDEX ROWID     Object owner=GL     Object name=GL_CODE_COMBINATIONS     Cost=2     Cardinality=1     Bytes=57
            INDEX UNIQUE SCAN     Object owner=GL     Object name=GL_CODE_COMBINATIONS_U1     Cost=1     Cardinality=1     
          TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_ITEM_LOCATIONS     Cost=3     Cardinality=1     Bytes=24
           INDEX RANGE SCAN     Object owner=INV     Object name=MTL_ITEM_LOCATIONS_U1     Cost=2     Cardinality=1     
         TABLE ACCESS BY INDEX ROWID     Object owner=HR     Object name=HR_ORGANIZATION_INFORMATION     Cost=2     Cardinality=1     Bytes=28
          INDEX RANGE SCAN     Object owner=HR     Object name=HR_ORGANIZATION_INFORMATIO_FK2     Cost=1     Cardinality=2     
        TABLE ACCESS BY INDEX ROWID     Object owner=HR     Object name=HR_ORGANIZATION_INFORMATION     Cost=1     Cardinality=1     Bytes=25
         INDEX RANGE SCAN     Object owner=HR     Object name=HR_ORGANIZATION_INFORMATIO_FK2     Cost=1     Cardinality=1     
       INDEX FULL SCAN     Object owner=GL     Object name=GL_SETS_OF_BOOKS_U2     Cost=1     Cardinality=1     Bytes=4
      BUFFER SORT               Cost=55     Cardinality=1     
       TABLE ACCESS FULL     Object owner=APPLSYS     Object name=FND_PRODUCT_GROUPS     Cost=3     Cardinality=1     

  • SQL Query Tuning issue

    A query run by the 'tom' user who searches on (xyz crieteria) takes less than 5 seconds.
    However, when the user 'greg' ruuns the same query, it take > 14 minutes to execute for same xyz crieteria.
    Note:both are application users and internally use DOCD database user.Both are using same SQL Explain plan but diffrence is disk read in case of long running query.
    my question is if both queries are same and using same explain plan and returning same rows why there is disk read???? and such huge diffrence in execution time...Below is the tkprof output for both the queries.
    QUICK QUERY
    ===========
    SELECT E_NAME, E_CURVER_NUM, E_CURVER_CKO, E_PROTECTED, E_INA01, E_INA26,
    E_INA47, V_FILE_NAME, E_ICON_TITLE, E_INA41, E_INA11, E_INA16, E_INA40,
    E_INA15, E_INA35, E_ORG_FILENAME, E_COMMENT, E_INA28, E_INA27,
    E_CREATE_DATE, E_OWNER, E_LAST_DATE, V_CHECKED_OUT, V_CHECKIN_USER, V_NAME,
    V_E_NAME, V_AVAIL_STAT, V_RECLAIM, V_PERMANENT, V_CSI_STATUS, V_CD, E_INA01,
    V_INA03, V_INA02, V_INA04, E_INA02, V_INA01, V_CREATE_DATE, E_INA03
    FROM
    ELEMENT, VERSION WHERE (NLS_UPPER(E_INA01) LIKE NLS_UPPER(:V001) AND
    NLS_UPPER(E_INA26) = NLS_UPPER(:V002) AND E_INA02 IS NULL AND (E_INA03 IS
    NULL OR E_INA03 = :V003) AND V_BRANCH_CURVER = :V004) AND ELEMENT.E_NAME =
    VERSION.V_E_NAME ORDER BY 12, 10 DESC, 1, 26, 25
    call count cpu elapsed disk query current rows
    Parse 1 0.01 0.00 0 0 0 0
    Execute 1 0.00 0.00 0 0 0 0
    Fetch 167 0.18 0.18 0 29466 0 1002
    total 169 0.20 0.19 0 29466 0 1002
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer goal: CHOOSE
    Parsing user id: 41
    Rows Row Source Operation
    1002 SORT ORDER BY (cr=29466 r=0 w=0 time=179192 us)
    8847 NESTED LOOPS (cr=29466 r=0 w=0 time=146638 us)
    14191 TABLE ACCESS FULL VERSION (cr=1082 r=0 w=0 time=25337 us)
    8847 TABLE ACCESS BY INDEX ROWID ELEMENT (cr=28384 r=0 w=0 time=97209 us)
    14191 INDEX UNIQUE SCAN UI256 (cr=14193 r=0 w=0 time=30388 us)(object id 29956)
    SLOW QUERY
    ==========
    SELECT E_NAME, E_CURVER_NUM, E_CURVER_CKO, E_PROTECTED, E_INA01, E_INA26,
    E_INA47, V_FILE_NAME, E_ICON_TITLE, E_INA41, E_INA11, E_INA16, E_INA40,
    E_INA15, E_INA35, E_ORG_FILENAME, E_COMMENT, E_INA28, E_INA27,
    E_CREATE_DATE, E_OWNER, E_LAST_DATE, V_CHECKED_OUT, V_CHECKIN_USER, V_NAME,
    V_E_NAME, V_AVAIL_STAT, V_RECLAIM, V_PERMANENT, V_CSI_STATUS, V_CD, E_INA01,
    V_INA03, V_INA02, V_INA04, E_INA02, V_INA01, V_CREATE_DATE, E_INA03
    FROM
    ELEMENT, VERSION WHERE (NLS_UPPER(E_INA01) LIKE NLS_UPPER(:V001) AND
    NLS_UPPER(E_INA26) = NLS_UPPER(:V002) AND E_INA02 IS NULL AND (E_INA03 IS
    NULL OR E_INA03 = :V003) AND V_BRANCH_CURVER = :V004) AND ELEMENT.E_NAME =
    VERSION.V_E_NAME ORDER BY 12, 10 DESC, 1, 26, 25
    call count cpu elapsed disk query current rows
    Parse 1 0.01 0.02 2 2 0 0
    Execute 1 0.01 0.00 0 0 0 0
    Fetch 167 0.29 1.18 2389 29466 0 1002
    total 169 0.32 1.21 2391 29468 0 1002
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer goal: CHOOSE
    Parsing user id: 41
    Rows Row Source Operation
    1002 SORT ORDER BY (cr=29466 r=2389 w=0 time=1180072 us)
    8847 NESTED LOOPS (cr=29466 r=2389 w=0 time=1144811 us)
    14191 TABLE ACCESS FULL VERSION (cr=1082 r=1078 w=0 time=134164 us)
    8847 TABLE ACCESS BY INDEX ROWID ELEMENT (cr=28384 r=1311 w=0 time=984455 us)
    14191 INDEX UNIQUE SCAN UI256 (cr=14193 r=137 w=0 time=127843 us)(object id 29956)

    Anuj,
    In the future, when posting items to the forum where spacing is critical to proper understanding, please use the { code } tags (without spaces) to retain the spacing.
    It appears that there is more to the story than what has been reported. It is good that you used tkprof, as it shows that there is more to the story. Taking a look at the two executions, the tkprof output shows that the first (quick) execution completed in 0.19 seconds, while the second (slow) execution completed in 1.21 seconds, even with th 2,391 blocks read from disk. My first question, if I were in the same situation, would be what would cause the first execution time to jump from 0.19 seconds to 5 seconds, and the second execution to jump from 1.21 seconds to 840 seconds (14 minutes)?
    In both cases, there is a library cache miss on both the parse and the execute calls - there may be some significance to this.
    In both cases, there were 167 fetch calls to return 1,002 rows, meaning that on average 6 rows were returned on each fetch.
    Let's assume that 'tom', whose query executed quickly, was connected to the database over a T1 connection with a 20ms (0.02 second) ping time. For siimplicity in calculation, assume that there were 170 round trips between the server and the client. The network communication between the client and the server would require at least 3.4 seconds, for a total time to send the query and retrieve the results of about 3.6 seconds. This is a little short of 5 seconds which you reported.
    Let's assume that 'greg', whose query executed slowly, was connected to the database over a satellite connection with a 2000ms (2 second) ping time. With the same number of round trips, the network communication would require about 340 seconds, for a total time to send the query and retrieve the results of about 341.21 seconds (5.7 minutes), about 8 minutes short of the target 14 minutes.
    Was this the only query executed by the clients, or were there multiple queries?
    Were the client computers on the same network segment?
    Did you gather a 10046 trace at level 8 or 12 for the sessions? If so, manually review the wait events in the trace files to see if it is possible to determine what was happening during the 14 minutes. Guessing can be fun, but sometimes you come up 8 minutes short by guessing alone.
    Charles Hooper
    IT Manager/Oracle DBA
    K&M Machine-Fabricating, Inc.

  • SQL INDEX USAGE

    hi,
    I have a procedure which took 15-20 minutes in the past to execute.Suddently it is taking 2 hours.When i examined i came to know that the sql statement is not using one of the index.I dropped the index and created it.The explain plan is generated but still the index is not being used.I forced the index usage by using the index hint
    SELECT /*+ INDEX(test_his test_hist_idx )*/ column 1.....
    But still it does not use the index.Please suggest me some advice on this?
    Thanks

    user589320 wrote:
    I have a procedure which took 15-20 minutes in the past to execute.Suddently it is taking 2 hours.When i examined i came to know that the sql statement is not using one of the index.I dropped the index and created it.The explain plan is generated but still the index is not being used.I forced the index usage by using the index hint
    SELECT /*+ INDEX(test_his test_hist_idx )*/ column 1.....
    I think you're going to have to post the entire text of your query if you want an answer, or people will simply be trying to guess what you've done wrong.
    Do you also have the full execution plan from before and after the change in performance ?
    If you do post the text, and plans, please use the 'code' tags to make the text readable.
    p.s. My shot in the dark guess, based on the text you've supplied, is that you've used the table name in the hint, rather than the table alias.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    "The temptation to form premature theories upon insufficient data is the bane of our profession."
    Sherlock Holmes (Sir Arthur Conan Doyle) in "The Valley of Fear".
    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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for