SQL  Statement tuning

Hi,
Some Sql statement is taking so much time to run. Performance wise it is very slow. How to tune Such SQL statemetns.Would you plase give steps for tuning.
Please any body reply on this...

Hi Satishbabu,
Try to get an PLAN on your sql statement, run EXPLAIN PLAN and check the statistics, if required, try using HINTS and see the difference in the COST.
Can you paste your sql statement in this forum?

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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How do i do the SQL Statement tuning

    I had a basic question
    After writing a query that satisfies the functional requirements - how do I optimize it's performance so that it runs faster.
    I would be grateful if you describe the query optimization process in detail..
    especially what should be the query on the plan table that is used to see the execution plan in hierarchial structure
    Thanking you in advance
    regards,
    Manoj Gokhale

    Hi,
    how do I optimize it's performance so that it runs faster.http://www.oracle.com/technology/oramag/webcolumns/2003/techarticles/burleson_cbo_pt1.html
    Start by gathering an execution plan (explain plan), and check-out autotrace:
    http://asktom.oracle.com/tkyte/article1/autotrace.html
    - Look for possible unnecessary large-table full-table scans, caused by missing indexes
    - Look for sub-optimal table join orders (see the ORDERED hint)
    - Look for sub-optimal table join methods (nested loops vs. hash join)
    You can adjust the execution plan in many ways:
    - Adding misisng indexes or building materialized views (see the 10g SQLAccess advisor). Here are my notes:
    http://www.dba-oracle.com/art_dbazine_911_pt5.htm
    - Hints (especially table join hints, ordered hint and optimizer mode hints). Only use "good" hints:
    http://www.dba-oracle.com/oracle_news/oracle_faq/faq_tune_hints_list.htm
    - Enhancing optimizer stats (especially missing histograms)
    http://www.dba-oracle.com/art_otn_cbo_p4.htm

  • Error ORA-29900 when tuning spatial sql statement for tuning task

    I am trying to tune a SQL statement and getting ORA-29900: operating binding does not exist and PLS-306 wrong number of arguments in call to SDO_FILTER. Oracle Version 11.1.
    Query trying to tune:
    Select ROUTE_LINK_ID,ROUTE_ID,ROUTE_SYSTEM_ID,ROUTE_SYSTEM_NAME,ASSIGNED_ROUTES_ID,
    GEOGRAPHIC_EXTENT_ID,GEOGRAPHIC_EXTENT_NAME,ROUTE_NAME,ROUTE_DIRECTION,FULL_NAME,
    OFFICIAL_NAME,ROUTE_LINK_ID,ORDINAL,DISTANCE,RELATIVE_DIRECTION,TRANSPORT_LINK_ID,
    GEOMETRY_GA_TW From IDOTLRS.ROUTE_DETAIL A where (ROUTE_SYSTEM_ID=8) AND
    MDSYS.SDO_FILTER(A.GEOMETRY_GA_TW, :GeometryFilter, 'querytype=window') = 'TRUE';
    Example query with bind variable populated:
    Select ROUTE_LINK_ID,ROUTE_ID,ROUTE_SYSTEM_ID,ROUTE_SYSTEM_NAME,ASSIGNED_ROUTES_ID,
    GEOGRAPHIC_EXTENT_ID,GEOGRAPHIC_EXTENT_NAME,ROUTE_NAME,ROUTE_DIRECTION,FULL_NAME,
    OFFICIAL_NAME,ROUTE_LINK_ID,ORDINAL,DISTANCE,RELATIVE_DIRECTION,TRANSPORT_LINK_ID,
    GEOMETRY_GA_TW From IDOTLRS.ROUTE_DETAIL A where (ROUTE_SYSTEM_ID=1) AND
    MDSYS.SDO_FILTER(A.GEOMETRY_GA_TW, SDO_GEOMETRY (2003, 1050010, NULL, sdo_elem_info_array (1, 1003, 3), sdo_ordinate_array (288325, 222066, 326949, 245295 )), 'querytype=window') = 'TRUE';
    --Tuning Task that throws error ORA-29900
    DECLARE
    my_task_name VARCHAR2(30);
    my_sqltext CLOB;
    BEGIN
    GeometryFilter := 'MDSYS.SDO_GEOMETRY(2003,1050010,NULL,MDSYS.sdo_elem_info_array(1,1003,3),mdsys.sdo_ordinate_array(288325,222066,326949,245295))';
    my_sqltext := 'Select ROUTE_LINK_ID,ROUTE_ID,ROUTE_SYSTEM_ID,ROUTE_SYSTEM_NAME,ASSIGNED_ROUTES_ID, GEOGRAPHIC_EXTENT_ID,GEOGRAPHIC_EXTENT_NAME,ROUTE_NAME,ROUTE_DIRECTION,FULL_NAME, OFFICIAL_NAME,ROUTE_LINK_ID,ORDINAL,DISTANCE,RELATIVE_DIRECTION,TRANSPORT_LINK_ID,GEOMETRY_GA_TW From IDOTLRS.ROUTE_DETAIL A where (ROUTE_SYSTEM_ID=1) AND MDSYS.SDO_FILTER(A.GEOMETRY_GA_TW, :GeometryFilter,''MASK=INSIDE'') = ''TRUE'' ';
    my_task_name := DBMS_SQLTUNE.CREATE_TUNING_TASK(
    sql_text => my_sqltext,
    bind_list => sql_binds(anyData.convertChar('MDSYS.SDO_GEOMETRY(2003,1050010,NULL,MDSYS.sdo_elem_info_array(1,1003,3),mdsys.sdo_ordinate_array(288325,222066,326949,245295))')),
    user_name => 'IDOTLRS',
    scope => 'COMPREHENSIVE',
    time_limit => 240,
    task_name => 'lrs_tuning_task_27',
    description => 'Task to tune a query on delete');
    END;
    BEGIN
    DBMS_SQLTUNE.EXECUTE_TUNING_TASK( task_name => 'lrs_tuning_task_27' );
    END;
    any advice would be appreciated to get the tuning task functioning.
    thanks in advance.

    convertObject allowed EXECUTE_TUNING_TASK to run, but stops with an end of file communication. I need to look and see why.
    ORA-03113: end-of-file on communication channel
    Process ID: 4676
    Session ID: 510 Serial number: 60166
    I will try the other option and see what happens.
    Will file a bug....
    Edited by: Eric Abrams on Sep 27, 2011 7:33 AM
    Appears to be logged.
    ORA-03113 reported when Enequeueing an ADT which contains a SYS.ANYDATA type [ID 799393.1], unpublished Bug 6830995
    Edited by: Eric Abrams on Sep 27, 2011 7:41 AM
    Edited by: Eric Abrams on Sep 27, 2011 7:42 AM

  • Tuning a stubborn SQL statement

    Hello,
    I have performance problems with this SQL statement:
    SELECT
      T_00 . "FBRNR" , T_00 . "FBFNR" , T_01 . "DIVISION" , T_01 . "SERVCODE" , T_01 . "KUNSND" ,
      T_01 . "KUNRCV" , T_01 . "KUNREG" , T_01 . "LFBED" , T_00 . "ABRDAT" , T_01 . "REGNL"
    FROM
      "ZFBINFO" T_00 , "ZFBDT" T_01
    WHERE
      ( T_01 . "MANDT" = :A0 AND T_00 . "FBRNR" = T_01 . "FBRNR" AND T_00 . "FBFNR" = T_01 . "FBFNR" )
      AND T_00 . "MANDT" = :A1 AND "DIVISION" = :A2 AND T_00 . "FBSTAT" <= :A3;
    On Oracle 9i it ran within 90 seconds and the execution plan was this:
    Execution Plan
    Plan hash value: 298645010
    | Id  | Operation                    | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |             |  1525K|   141M|  5595K  (1)| 09:33:38 |
    |   1 |  NESTED LOOPS                |             |  1525K|   141M|  5595K  (1)| 09:33:38 |
    |   2 |   TABLE ACCESS BY INDEX ROWID| ZFBINFO     |  9152K|   305M| 97247   (1)| 00:09:59 |
    |*  3 |    INDEX RANGE SCAN          | ZFBINFO~B   |  9152K|       |  6121   (2)| 00:00:38 |
    |*  4 |   TABLE ACCESS BY INDEX ROWID| ZFBDT       |     1 |    62 |     1   (0)| 00:00:01 |
    |*  5 |    INDEX UNIQUE SCAN         | ZFBDT_____0 |     1 |       |     0   (0)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
         302386  consistent gets
          19689  physical reads
    After an upgrade to Oracle 10g the statement runs for more than 8 minutes and the execution plan is like this:
    Execution Plan
    Plan hash value: 4079065069
    | Id  | Operation                    | Name      | Rows  | Bytes |TempSpc| Cost(%CPU)| Time     |
    |   0 | SELECT STATEMENT             |           |  1525K|   141M|       |   909K  (4)| 01:33:13 |
    |*  1 |  HASH JOIN                   |           |  1525K|   141M|   410M|   909K  (4)| 01:33:13 |
    |   2 |   TABLE ACCESS BY INDEX ROWID| ZFBINFO   |  9152K|   305M|       | 97247  (1)| 00:09:59 |
    |*  3 |    INDEX RANGE SCAN          | ZFBINFO~B |  9152K|       |       |  6121   (2)| 00:00:38 |
    |*  4 |   TABLE ACCESS FULL          | ZFBDT     |    25M|  1535M|       |   716K  (4)| 01:13:26 |
    Statistics
            495  recursive calls
             66  db block gets
        4709177  consistent gets
        4691042  physical reads
    I have asked the SQL Tuning Advisor to tune this statement on Oracle 10g, but it
    believes the "TABLE ACCESS FULL" on table ZFBDT is the best way for this statement.
    The index ZFBDT_____0 is defined on columns MANDT, FBRNR, FBFNR, so not suprisingly
    if I add a hint manually /+INDEX(T_01, "ZFBDT_____0") / then the statement  runs 5 times
    faster and requires only very few physical and logical reads.
    How can I convince the Oracle 10g optimizer to use the primary key index on ZFBDT?
    Regards,
    Mark

    Hello Martin,
    the tables ZFBDT and ZFBINFO have got 155 million rows. When
    checking the bind variables I can see the condition FBSTAT<=70.
    The SQL statement selects only 58000 entries from table ZFBINFO:
    FB   COUNT(*)
    00          3
    10      33151
    20       5657
    28         28
    30      11971
    40       1734
    50        163
    55       5934
    72        437
    73      17355
    74      49113
    75      24438
    76        529
    78     122828
    80  139801614
    82   11099678
    85    3054910
    90    1627482
    So I say the selection on FBSTAT is really selective.
    However, I don't see how manipulating the CBO statistics
    (as described in SAP note 724545) would help here.
    Regards,
    Mark

  • SQL Tuning Advisor on a specific SQL statement

    Hi all,
    How can I used SQL Tuning Advisor in Oracle EM Database Control to tune a specific SQL statement; i.e. the statement is not any of: Top SQL, SQL Tuning Sets, Snapshots Preserved Snapshot Sets.
    Thanks in advance,
    Ahmed B.

    Hi,
    You can use either the automatic SQL tuning features that are accessible from Enterprise Manager Database Console on the "Advisor Central" page or trough SQL*PLUS using the DBMS_SQLTUNE pakage:
    -- creating the tuning task
    set serveroutput on
    declare
      l_sql_tune_task_id  varchar2(100);
    begin
      l_sql_tune_task_id := dbms_sqltune.create_tuning_task (
                              sql_id      => '<your_sql_id>',
                              scope       => dbms_sqltune.scope_comprehensive,
                              time_limit  => 60,
                              task_name   => '<your_tuning_task_name>',
                              description => 'tuning task for statement your_sql_id.');
      dbms_output.put_line('l_sql_tune_task_id: ' || l_sql_tune_task_id);
    end;
    -- executing the tuning task
    exec dbms_sqltune.execute_tuning_task(task_name => '<your_tuning_task_name>');
    -- displaying the recommendations
    set long 100000;
    set longchunksize 1000
    set pagesize 10000
    set linesize 100
    select dbms_sqltune.report_tuning_task('<your_tuning_task_name>') as recommendations from dual;For more information, take a look at link provided by Jaffy.
    Cheers
    Legatti

  • How to Run SQL Tuning Advisor on the SQL statement with SQL_ID?

    Can you give the steps to run the SQL tuning advisor on the SQL statement with SQL_ID?
    Database version: 10g Release 2

    Hi,
    You can use either the automatic SQL tuning features that are accessible from Enterprise Manager Database Console on the "Advisor Central" page or trough SQL*PLUS using the DBMS_SQLTUNE pakage:
    -- creating the tuning task
    set serveroutput on
    declare
      l_sql_tune_task_id  varchar2(100);
    begin
      l_sql_tune_task_id := dbms_sqltune.create_tuning_task (
                              sql_id      => '<your_sql_id>',
                              scope       => dbms_sqltune.scope_comprehensive,
                              time_limit  => 60,
                              task_name   => '<your_tuning_task_name>',
                              description => 'tuning task for statement your_sql_id.');
      dbms_output.put_line('l_sql_tune_task_id: ' || l_sql_tune_task_id);
    end;
    -- executing the tuning task
    exec dbms_sqltune.execute_tuning_task(task_name => '<your_tuning_task_name>');
    -- displaying the recommendations
    set long 100000;
    set longchunksize 1000
    set pagesize 10000
    set linesize 100
    select dbms_sqltune.report_tuning_task('<your_tuning_task_name>') as recommendations from dual;For more information, take a look at link provided by Jaffy.
    Cheers
    Legatti

  • Tuning an sql from a vendor product without modifying the sql statement

    Hi,
    we have a vendor product which generates SQL Statement. For one query, we get response in 15 seconds. But users are asking if we can bring it down to 5 seconds. Limitation is query can't be changed. It used around 10 to 12 tables and bit complex query.
    What kind of options could be evaluated if we want to improve performance of a query (Not sure if it could be ever reduced to 5 seconds)
    without making any change to the query.
    Database Version: Oracle 10.2.0.4
    Thanks,
    Sarayu

    807778 wrote:
    Hi,
    we have a vendor product which generates SQL Statement. For one query, we get response in 15 seconds. But users are asking if we can bring it down to 5 seconds. Limitation is query can't be changed. It used around 10 to 12 tables and bit complex query.
    What kind of options could be evaluated if we want to improve performance of a query (Not sure if it could be ever reduced to 5 seconds)
    without making any change to the query.
    Database Version: Oracle 10.2.0.4
    Thanks,
    SarayuI'd go through the standard stuff of "is there an index that can help?", "should these tables be in a cluster?" etc.. Problem there is that you might degrade other operations, and you might break your application support contract by modifying the schema. Even adding a materialized view could do that.

  • ABAP Standards for a SQL statement

    Hi,
    I have a Native SQL statement in my ABAP user exit, pls. edit into a Open SQL,
    SELECT v1~tknum v1~tsnum
          INTO TABLE t_vtts
          FROM vtts AS v1
          FOR ALL ENTRIES IN t_shipment_del
          WHERE v1~tknum = t_shipment_del-tknum AND
                v1~vstel = rv_shppt          AND
                v1~kunnz = rv_shipto         AND
                v1~tsrfo = c_one             AND
                EXISTS ( SELECT addrnumber
                           FROM adrc CLIENT SPECIFIED
                           WHERE client     =  v1~mandt AND
                                 addrnumber =  v1~adrnz AND
                                 date_from  <= sy-datum AND
                                 date_to    >= sy-datum AND
                                 post_code1 =  rv_post_code1 ).
    Thank you

    Hhmm, for proper performance analysis we'd need some further details. Looking at your query I doubt that the following alternative helps, but you can give it a try, because subqueries are not always optimal:
      SELECT tknum tsnum INTO TABLE t_vtts
             FROM vtts INNER JOIN adrc ON
                  vtts~adrnz = adrc~addrnumber
             FOR ALL entries IN t_shipment_del
             WHERE tknum      = t_shipment_del-tknum AND
                   vstel      = rv_shppt             AND
                   kunnz      = rv_shipto            AND
                   tsrfo      = c_one                AND
                   post_code1 = rv_post_code1.
    You might need to add the condition on the address dates, but in any system I've checked so far, the ADRC-FROM date was always 00010101 and there was only one entry per address number (so if required, add it back).
    For performance tuning requests you should try to provide some background information, like:
    <ol>
    <li>How many entries are you your table T_SHIPMENT_DEL</li>
    <li>How many entries match your conditions on VTTS</li>
    <li>How many entries get dropped because of the condition on postal code</li>
    <li>Do a SQL trace and provide information about the execution plan chosen by the database</li>
    </ol>
    Also, you might want to consider moving your question to the forum.
    Cheers, harald

  • SQL Statement Tunning Request

    Please help to tune the below query. I have provided following information
    1. Query To be tuned
    2. Parameter Relevant to Optimizer
    3. Explain Plan and AutoTrace Ouput
    4. Query traced at Level 8 and Its Tkprof Ouput
    5. EXPLAIN PLAN output of DBMS_XPLAN.DISPLAY
    INFORMATION 1. SQL QUERY TO BE TUNED
    SELECT DISTINCT C.MAN_WIP_T_IN_TS,
    C.RCP_NO,
    C.WRK_CTR_ID,
    C.WTR_FREE_TST_FLG,
    A.COMPANY_ID,
    A.PROD_ORDER,
    A.PART_NO,
    A.CARRIER_QTY,
    B.PHY_CARID,
    C.WIP_SEQ,
    A.RCP_NO "CARRIER_RCP"
    FROM dbadmintest.PF2_PROD_ORDER_CARRIER A,
    PF2_PHYSICAL_CARRIER B,
    WORK_IN_PROCESS C
    WHERE C.UNIT_TYPE_CD = RTRIM('TL7')
    AND C.UNIT_NM = RTRIM('T41')
    AND C.WIP_TYPE_CD = 'HANDHELD'
    AND C.PHY_CARRIER_SEQ = A.PHY_CARRIER_SEQ
    AND A.PHY_CARRIER_SEQ = B.PHY_CARRIER_SEQ
    AND ((A.CARRIER_LD_TS <= C.MAN_WIP_T_IN_TS
    AND A.CARRIER_UNLD_TS >= C.MAN_WIP_T_IN_TS)
    OR ( A.CARRIER_LD_TS <= C.MAN_WIP_T_IN_TS
    AND A.CARRIER_UNLD_TS IS NULL))
    AND ((A.CARRIER_UNLD_TS >= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
    AND A.CARRIER_UNLD_TS <= TO_DATE('2012-01-12 10:03:00', 'YYYY-MM-DD HH24:MI:SS'))
    OR (A.CARRIER_LD_TS >= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
    AND A.CARRIER_LD_TS <= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS'))
    OR (A.CARRIER_LD_TS <= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
    AND A.CARRIER_UNLD_TS IS NULL)
    OR (A.CARRIER_LD_TS <= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
    AND A.CARRIER_UNLD_TS >= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')))
    ORDER BY 6,5,1
    INFORMATION 2. PARAMETER RELEVANT TO OPTIMIZER
    NAME           TYPE      VALUE
    optimizer_dynamic_sampling      integer      2
    optimizer_features_enable      string      10.2.0.4
    optimizer_index_caching      integer      0
    optimizer_index_cost_adj      integer      100
    optimizer_mode           string      ALL_ROWS
    optimizer_secure_view_merging      boolean      TRUE
    db_file_multiblock_read_count      integer      16
    cursor_sharing           string      EXACT
    SQL> column sname format a20          
    column pname format a20          
    column pval2 format a20          
    select          
    sname          
    , pname          
    , pval1          
    , pval2          
    from sys.aux_stats$;SQL>      
    SNAME      PNAME      PVAL1      PVAL2
    SYSSTATS_INFO      STATUS           COMPLETED
    SYSSTATS_INFO      DSTART           08-25-2009 07:27
    SYSSTATS_INFO      DSTOP           08-25-2009 07:27
    SYSSTATS_INFO      FLAGS      1
    SYSSTATS_MAIN      CPUSPEEDNW      1592.87183
    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
    INFORMATION 3. EXPLAIN PLAN AND AUTOTRACE OUTPUT
    Execution Plan
    Plan hash value: 850402268
    | Id | Operation                | Name                | Rows      | Bytes      | Cost (%CPU)     | Time      |
    | 0 | SELECT STATEMENT           |                | 11      | 1100      | 1568      (1)     | 00:00:19      |
    | 1 | SORT UNIQUE                |                | 11      | 1100      | 1567      (1)     | 00:00:19      |
    |* 2 | HASH JOIN                |                | 11      | 1100      | 1566      (1)     | 00:00:19      |
    |* 3 | TABLE ACCESS BY INDEX ROWID      | PF2_PROD_ORDER_CARRIER      | 5      | 270      | 763      (0)     | 00:00:10      |
    | 4 | NESTED LOOPS           |                | 11      | 1001      | 1562      (1)     | 00:00:19      |
    |* 5 | TABLE ACCESS BY INDEX ROWID     | WORK_IN_PROCESS           | 2      | 74      | 35      (0)     | 00:00:01      |
    |* 6 | INDEX RANGE SCAN           | WORK_IN_PROCESS_IX2           | 56      |      | 3      (0)     | 00:00:01      |
    |* 7 | INDEX RANGE SCAN           | PF2_PROD_ORDER_CARRIER_IX3      | 2361      |      | 6      (0)     | 00:00:01      |
    | 8 | TABLE ACCESS FULL           | PF2_PHYSICAL_CARRIER           | 1736      | 15624      | 4      (0)     | 00:00:01 |
    Predicate Information (identified by operation id):
    2 - access("A"."PHY_CARRIER_SEQ"="B"."PHY_CARRIER_SEQ")
    3 - filter(("A"."CARRIER_UNLD_TS" IS NULL AND "A"."CARRIER_LD_TS"<=TO_DATE(' 2012-01-12 08:03:00',
    'syyyy-mm-dd hh24:mi:ss') OR "A"."CARRIER_UNLD_TS">=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd
    hh24:mi:ss') AND "A"."CARRIER_LD_TS"<=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd hh24:mi:ss') OR
    "A"."CARRIER_UNLD_TS">=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd hh24:mi:ss') AND
    "A"."CARRIER_UNLD_TS"<=TO_DATE(' 2012-01-12 10:03:00', 'syyyy-mm-dd hh24:mi:ss') OR
    "A"."CARRIER_LD_TS"=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd hh24:mi:ss')) AND
    ("A"."CARRIER_LD_TS"<="C"."MAN_WIP_T_IN_TS" AND "A"."CARRIER_UNLD_TS">="C"."MAN_WIP_T_IN_TS" OR
    "A"."CARRIER_UNLD_TS" IS NULL AND "A"."CARRIER_LD_TS"<="C"."MAN_WIP_T_IN_TS"))
    5 - filter("C"."WIP_TYPE_CD"='HANDHELD' AND "C"."PHY_CARRIER_SEQ" IS NOT NULL)
    6 - access("C"."UNIT_TYPE_CD"='TL7' AND "C"."UNIT_NM"='T41')
    7 - access("C"."PHY_CARRIER_SEQ"="A"."PHY_CARRIER_SEQ")
    filter("A"."PHY_CARRIER_SEQ" IS NOT NULL)
    Statistics
    1           recursive calls
    0           db block gets
    13525998      consistent gets
    7024           physical reads
    0           redo size
    1758           bytes sent via SQL*Net to client
    492           bytes received via SQL*Net from client
    2           SQL*Net roundtrips to/from client
    1           sorts (memory)
    0           sorts (disk)
    14           rows processed
    INFORMATION 4. QUERY TRACES AT LEVEL 8 AND TKPROF OUTPUT
    TKPROF: Release 10.2.0.4.0 - Production on Wed Jan 18 01:48:53 2012
    Copyright (c) 1982, 2007, Oracle. All rights reserved.
    Trace file: ././ppf2_ora_5439924.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 DISTINCT C.MAN_WIP_T_IN_TS,
    C.RCP_NO,
    C.WRK_CTR_ID,
    C.WTR_FREE_TST_FLG,
    A.COMPANY_ID,
    A.PROD_ORDER,
    A.PART_NO,
    A.CARRIER_QTY,
    B.PHY_CARID,
    C.WIP_SEQ,
    A.RCP_NO "CARRIER_RCP"
    FROM PF2_PROD_ORDER_CARRIER A,
    PF2_PHYSICAL_CARRIER B,
    WORK_IN_PROCESS C
    WHERE C.UNIT_TYPE_CD = RTRIM('TL7')
    AND C.UNIT_NM = RTRIM('T41')
    AND C.WIP_TYPE_CD = 'HANDHELD'
    AND C.PHY_CARRIER_SEQ = A.PHY_CARRIER_SEQ
    AND A.PHY_CARRIER_SEQ = B.PHY_CARRIER_SEQ
    AND ((A.CARRIER_LD_TS <= C.MAN_WIP_T_IN_TS
    AND A.CARRIER_UNLD_TS >= C.MAN_WIP_T_IN_TS)
    OR ( A.CARRIER_LD_TS <= C.MAN_WIP_T_IN_TS
    AND A.CARRIER_UNLD_TS IS NULL))
    AND ((A.CARRIER_UNLD_TS >= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
    AND A.CARRIER_UNLD_TS <= TO_DATE('2012-01-12 10:03:00', 'YYYY-MM-DD HH24:MI:SS'))
    OR (A.CARRIER_LD_TS >= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
    AND A.CARRIER_LD_TS <= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS'))
    OR (A.CARRIER_LD_TS <= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
    AND A.CARRIER_UNLD_TS IS NULL)
    OR (A.CARRIER_LD_TS <= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
    AND A.CARRIER_UNLD_TS >= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')))
    ORDER BY 6,5,1
    call      count      cpu      elapsed disk      query      current rows
    Parse      1      0.00      0.00      0      0      0      0
    Execute 1      0.00      0.00      0      0      0      0
    Fetch      2      219.55      294.41      14030      13523455 0      14
    total      4      219.55      294.41      14030      13523455 0      14
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: SYS
    Rows           Row Source Operation
    14           SORT UNIQUE (cr=13523455 pr=14030 pw=0 time=294417731 us)
    14           HASH JOIN (cr=13523455 pr=14030 pw=0 time=294416444 us)
    14           TABLE ACCESS BY INDEX ROWID PF2_PROD_ORDER_CARRIER (cr=13523440 pr=14030 pw=0 time=292675360 us)
    98184018      NESTED LOOPS (cr=270067 pr=9028 pw=0 time=294901120 us)
    12128           TABLE ACCESS BY INDEX ROWID WORK_IN_PROCESS (cr=9842 pr=8788 pw=0 time=20479883 us)
    15241      INDEX RANGE SCAN WORK_IN_PROCESS_IX2 (cr=49 pr=48 pw=0 time=54577 us)(object id 65980)
    98171889      INDEX RANGE SCAN PF2_PROD_ORDER_CARRIER_IX3 (cr=260225 pr=240 pw=0 time=808956 us)(object id 65990)
    1736           TABLE ACCESS FULL PF2_PHYSICAL_CARRIER (cr=15 pr=0 pw=0 time=83 us)
    Elapsed times include waiting on following events:
    Event waited on      Times      Max. Wait      Total Waited
    ----------------------------------------      Waited      ----------           ------------
    SQL*Net message to client          3      0.00           0.00
    SQL*Net message from client      3      0.00           0.00
    db file sequential read      14030      0.47           43.56
    call      count      cpu      elapsed     disk     query     current     rows
    Parse      1      0.00      0.00      0      0      0      0
    Execute 1      0.00      0.00      0      0      0      0
    Fetch      0      0.00      0.00      0      0      0      0
    total      2      0.00      0.00      0      0      0      0
    Misses in library cache during parse: 0
    Parsing user id: SYS
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call      count      cpu      elapsed     disk      query      current      rows
    Parse      2      0.00      0.00      0      0      0      0
    Execute 2      0.00      0.00      0      0      0      0
    Fetch      2      219.55      294.41      14030      13523455 0      14
    total      6      219.55      294.41      14030      13523455 0 14
    Misses in library cache during parse: 0
    Elapsed times include waiting on following events:
    Event waited on      Times      Max. Wait      Total Waited
    ----------------------------------------      Waited      ----------           ------------     
    SQL*Net message to client      3      0.00           0.00
    SQL*Net message from client      3      0.00           0.00
    db file sequential read      14030      0.47           43.56
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    call      count cpu      elapsed      disk      query      current      rows
    Parse      0      0.00      0.00      0      0      0      0
    Execute 0      0.00      0.00      0      0      0      0
    Fetch      0      0.00      0.00      0      0      0      0
    total      0      0.00      0.00      0      0      0      0
    Misses in library cache during parse: 0
    2 user SQL statements in session.
    0 internal SQL statements in session.
    2 SQL statements in session.
    Trace file: ././ppf2_ora_5439924.trc
    Trace file compatibility: 10.01.00
    Sort options: default
    1      session in tracefile.
    2      user SQL statements in trace file.
    0      internal SQL statements in trace file.
    2      SQL statements in trace file.
    2      unique SQL statements in trace file.
    14137      lines in trace file.
    294      elapsed seconds in trace file.
    INFORMATION 5. EXPLAIN PLAN OUTPUT OF DBMS_XPLAN.DISPLAY
    SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
    PLAN_TABLE_OUTPUT
    SQL_ID 1z1cccq5kxt11, child number 0
    SELECT /*+ gather_plan_statistics */ DISTINCT C.MAN_WIP_T_IN_TS, C.RCP_NO, C.WRK_CTR_ID, C.WTR_FREE_TST_FLG,
    A.COMPANY_ID, A.PROD_ORDER, A.PART_NO, A.CARRIER_QTY, B.PHY_CARID, C.WIP_SEQ, A.RCP_NO "CARRIER_RCP"
    FROM PF2_PROD_ORDER_CARRIER A, PF2_PHYSICAL_CARRIER B, WORK_IN_PROCESS C
    WHERE C.UNIT_TYPE_CD = RTRIM('TL7') AND C.UNIT_NM = RTRIM('T41') AND C.WIP_TYPE_CD ='HANDHELD'
    AND C.PHY_CARRIER_SEQ = A.PHY_CARRIER_SEQ AND A.PHY_CARRIER_SEQ = B.PHY_CARRIER_SEQ
    AND ((A.CARRIER_LD_TS <=C.MAN_WIP_T_IN_TS AND A.CARRIER_UNLD_TS >= C.MAN_WIP_T_IN_TS) OR
    ( A.CARRIER_LD_TS <= C.MAN_WIP_T_IN_TS AND A.CARRIER_UNLD_TS IS NULL)) AND ((A.CARRIER_UNLD_TS >= TO_DATE('2012-01-12
    08:03:00', 'YYYY-MM-DD HH24:MI:SS') AND A.CARRIER_UNLD_TS<= TO
    Plan hash value: 850402268
    | Id | Operation                     | Name                    | Starts      |E-Rows      | A-Rows      |A-Time           | Buffers      | Reads      |OMem      |1Mem      | Used-Mem      |
    | 1 | SORT UNIQUE                     |                | 1      | 11      | 14      |00:05:41.48      | 13M     | 6571      | 2048      | 2048      | 2048 (0)          |
    |* 2 | HASH JOIN                     |                | 1      | 11      | 14      |00:05:41.48      | 13M     | 6571      | 807K     | 807K     | 614K (0)          |
    |* 3 | TABLE ACCESS BY INDEX ROWID           | PF2_PROD_ORDER_CARRIER      | 1      | 5      | 14      |00:05:39.89      | 13M     | 6571      |      |      |           |
    | 4 | NESTED LOOPS                |                | 1      | 11      | 98M     |00:04:55.08      | 270K     | 6569      |      |      |           |
    |* 5 | TABLE ACCESS BY INDEX ROWID          | WORK_IN_PROCESS           | 1      | 2      | 12130      |00:00:13.15      | 9845      | 6569      |      |      |           |
    |* 6 | INDEX RANGE SCAN                | WORK_IN_PROCESS_IX2           | 1      | 56      | 15244      |00:00:00.06      | 49      | 45      |      |      |           |
    |* 7 | INDEX RANGE SCAN                | PF2_PROD_ORDER_CARRIER_IX3      | 12130      | 2361      | 98M     |00:00:00.92      | 260K     | 0      |      |      |           |
    | 8 | TABLE ACCESS FULL                | PF2_PHYSICAL_CARRIER           | 1      | 1736      | 1736      |00:00:00.01      | 15      | 0      |      |      |           |
    Predicate Information (identified by operation id):
    2 - access("A"."PHY_CARRIER_SEQ"="B"."PHY_CARRIER_SEQ")
    3 - filter(((("A"."CARRIER_UNLD_TS" IS NULL AND "A"."CARRIER_LD_TS"<=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd hh24:mi:ss')) OR
    ("A"."CARRIER_UNLD_TS">=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd hh24:mi:ss') AND "A"."CARRIER_LD_TS"<=TO_DATE(' 2012-01-12 08:03:00',
    'syyyy-mm-dd hh24:mi:ss')) OR ("A"."CARRIER_UNLD_TS">=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd hh24:mi:ss') AND
    "A"."CARRIER_UNLD_TS"<=TO_DATE(' 2012-01-12 10:03:00', 'syyyy-mm-dd hh24:mi:ss')) OR "A"."CARRIER_LD_TS"=TO_DATE(' 2012-01-12 08:03:00',
    'syyyy-mm-dd hh24:mi:ss')) AND (("A"."CARRIER_LD_TS"<="C"."MAN_WIP_T_IN_TS" AND "A"."CARRIER_UNLD_TS">="C"."MAN_WIP_T_IN_TS") OR
    ("A"."CARRIER_UNLD_TS" IS NULL AND "A"."CARRIER_LD_TS"<="C"."MAN_WIP_T_IN_TS"))))
    5 - filter(("C"."WIP_TYPE_CD"='HANDHELD' AND "C"."PHY_CARRIER_SEQ" IS NOT NULL))
    6 - access("C"."UNIT_TYPE_CD"='TL7' AND "C"."UNIT_NM"='T41')
    7 - access("C"."PHY_CARRIER_SEQ"="A"."PHY_CARRIER_SEQ")
    filter("A"."PHY_CARRIER_SEQ" IS NOT NULL)
    41 rows selected.
    Regards
    Rahul

    Rahul, post your question on the SQL and PL/SQL forum PL/SQL. This forum is for Oracle Berkeley DB not Oracle Database.
    Thanks,
    Andrei

  • Expensive SQL statements in GTS

    Hi,
    Recently EWA has been run for the GTS system.There are expensive SQL statements that were causing the Performance issue.It would be a great help if anyone can advise on how these expensive SQL statments can be fine tuned. As all these statements were in standard SAP programs is it that we had the only option to create secondary indices ?
    Moderator message - Please respect the 5,000 character maximum when posting. Post only the relevant portions of code
    Please see Please Read before Posting in the Performance and Tuning Forum before posting
    Any suggestion on performance improvement is appreciated.
    Thanks in advance!!
    Regards,
    Sharon.
    Edited by: Rob Burbank on Nov 15, 2010 9:08 AM

    please ask specific questions.
    Otherwise there are services by SAP, either training or support, but they are not for free.
    Siegfried

  • How to monitor worst performing sql statements

    Hi,
    I am new to oracle 9i release 2. I come from the Windows world, where we used sql server.
    When we performanced tested our product, we always monitor the worst performaning sql statement using the sql profiler. At the end of a 24 hour test, the profiler will list the sql statement with the longest execution time. What is the equivalent Oracle 9i tools that will allow me to monitor the worst performaning sql during a test that lasts between 10 to 24 hours?
    Thanks,
    Paul0al

    Besides statspack and OEM you have a few other options.
    If an SQL statement had been identified as performing poorly or a job that you can extract the SQL from then you have the option of explaining all the SQL statements and just reviewing the plans for reasonableness. You can also trace actual execution of the task or individual statemnts (alter session set sql_trace = true for basic 10046 event).
    When the SQL has not been identified in advance you can query the shared pool SQL areas for SQL statements that have relatively high physical, logical, or combined IO counts. Then you can perform tuning activities for these statements.
    HTH -- Mark D Powell --

  • ORA-01555 caused by SQL statement below on production

    Hi
    i got ORA-01555 caused by SQL statement below on my prodution adn database undo_retention = 18000 what can i do my database performance is going down pls tail me what i do .
    Regards
    Digvijay

    1) I don't see a SQL statement here
    3) How did you determine that UNDO_RETENTION of 18000 was appropriate?
    4) How much UNDO is your system generating?
    6) Do you believe this is related to your performance problems? If so, why do you believe that?
    At the risk of stating the obvious... You've told Oracle to try to maintain UNDO for 18,000 seconds (5 hours). You have a query that runs for roughly 6.25 hours. If, after running for 6.25 hours, that query needs a block that was modified, say, 6 hours ago, it may not find it because you've told Oracle you don't need it any longer.
    Your UNDO_RETENTION needs to be greater than the longest-running query you expect to run. You can bump up UNDO_RETENTION if you'd like. However, I tend to believe that a query that died after 6.25 hours is probably a query that is in desparate need of tuning. If you reduce the query runtime to something less than 5 hours, you could keep UNDO_RETENTION at the current setting.
    Justin

  • Time Consuming SQL Statements

    Hi All
    I am working on Performance Tuning on Oracle 10g/ Solaris environment.
    I am looking for a shell script that gives top 10 Time Consuming SQL Statements...... My client does not want me to use statspack or OEM for somereasons which i dont know.
    I am wondering if any of you might help me out ....
    Please post your script here ...........
    thanks in advance
    riah

    Hi,
    might be the script from Steve Adams site gives you some ideas
    -- Script:     expensive_sql.sql
    -- Purpose:     to find expensive sql that may need tuning
    -- Copyright:     (c) 2000 Ixora Pty Ltd
    -- Author:     Steve Adams
    @save_sqlplus_settings
    prompt This script shows SQL statement that account for more than
    prompt a certain percentage of disk reads.
    prompt
    @accept Percent "Threshold percentage of disk reads" 2.5
    column executes format 9999999
    break on load on executes
    select
    substr(
    to_char(
    100 * s.disk_reads / t.total_disk_reads,
    '99.00'
    2
    ) ||
    '%' load,
    s.executions executes,
    p.sql_text
    from
    ( select sum(disk_reads) total_disk_reads from sys.v_$sql ) t,
    sys.v_$sql s,
    sys.v_$sqltext p
    where
    (100 * s.disk_reads / t.total_disk_reads > &Percent)
    and s.disk_reads > 50 * s.executions and
    p.address = s.address
    order by
    1, s.address, p.piece
    undefine Percent
    @restore_sqlplus_settings
    Hope this helps,
    Andrey

  • Expensive SQL Statements of the day?

    Hi...
    How can i find out Expensive SQL Statements of the day please.?
    Our SAP Version is ECC 6.0 on Oracle 10.2.0.4.0
    Rgds

    Hi Srinivas,
    On ECC 6.0, go to ST04 t-code --> performance --> SQL Cache --> You see SQL Statements where you need to sort by SQL Statements by Total Execution Time(ms).
    I have tried on one of my R/3 4.7EE system, ST04n --> Resource COnsumption --> Top SQL Statements --> you will see 50 Top most expensive SQL Statements interms of wait time.
    also Read: [Re: Diagnosis of the expensive ABAP programs having database time > 90%;
                      [Please Read before Posting in the Performance and Tuning Forum;
    Regards,
    Kanthi Kiran

Maybe you are looking for