How To Optimize a query

Hi,
I need to optimize or rewrite the following query, is there anyone who can help me?
SELECT *
  FROM
        SELECT a.CONTRACT_ID AS SERVICE_ORDER_HEAD_ID,
               C.CONDITION_TYPE_ID,
               b.VALUE_CONDITION_AMT AS AMOUNT,
               b.BASE_CONDITION_AMT  AS BASE_AMOUNT,
               b.TOTAL_AMT           AS TOT_AMOUNT
          FROM QTST_CONTRACT_PRICE_COND A,
               COPE_ORDER_CONDITION B,
               COSM_ORDER_CONDITION_DE_L C,
               COSM_CONDITION_CLASS_L D,
               COSM_CONDITION_METHOD_L E,
--- PARTE MODIFICATA   
               MT_SETUP_PARAMETERS M,  
               SRST_SERVICE_ORDER_ITEM S       
         WHERE A.PRICE_CONDITION_ID = B.PRICE_CONDITION_ID(+)
           AND A.POSITION_ID          = B.POSITION_ID(+)
           AND A.LEVEL_ID             = B.LEVEL_ID(+)
           AND A.CONDITION_COUNTER_ID = B.CONDITION_COUNTER_ID(+)
           AND B.APPL_FK              = C.APPL_ID(+)
           AND B.USAGE_FK             = C.USAGE_ID(+)
           AND B.CONDITION_TYPE_FK    = C.CONDITION_TYPE_ID(+)
           AND B.CONDITION_CLASS_FK = D.CONDITION_CLASS_ID(+)
           AND B.CONDITION_METHOD_FK = E.CONDITION_METHOD_ID(+)
--- PARTE MODIFICATA
--          AND a.POSITION_ID IN  ( SELECT SERVICE_ORDER_ITEM_ID FROM SRST_SERVICE_ORDER_ITEM )
           AND a.POSITION_ID  = S.SERVICE_ORDER_ITEM_ID
           AND A.CONDITION_COUNTER_ID = (SELECT MAX(A_I.CONDITION_COUNTER_ID)
                                           FROM QTST_CONTRACT_PRICE_COND A_I
                                          WHERE a.CONTRACT_ID      = a_i.CONTRACT_ID
                                            AND a.PRICE_CONDITION_ID = a_i.PRICE_CONDITION_ID
                                            AND a.POSITION_ID        = a_i.POSITION_ID
                                            AND a.LEVEL_ID           = a_i.LEVEL_ID
--- PARTE MODIFICATA
            AND B.CONDITION_TYPE_FK = M.parameter_value_id
            AND m.object_name_id = 'SRSA_SERVICE_ORDER_CONDITION'
            and m.field_id = 'CONDITION_TYPE_FK'
            and m.x_delete = '0'
    ) pivot (MAX(AMOUNT) AS AMOUNT,
             MAX(BASE_AMOUNT) AS BASE_AMOUNT,
             MAX(TOT_AMOUNT) AS TOT_AMOUNT
             FOR CONDITION_TYPE_ID IN ('ZIAC' ROLE, 'ZIAD' RECOVERY_COMP, 'ZIAE' ROLE_TOTAL, 'ZIAF' CANCEL_REQU,
                                       'ZIAG' PAYMENTS, 'ZIAH' CANCEL_OBT, 'ZIAI' REC_BY_REMB, 'ZIAJ' CREDIT_NOTE,
                                       'ZIAK' BILL_TO_CUST, 'ZIAL' CHARGED_TO_SUPPL, 'ZIAM' CHARGED_TO_CUST, 'ZIAN' RECHARGE_CUST,
                                       'ZIAO' POSTAGE, 'ZIAV' FINE_TO_PAY, 'ZIAW' SUPPLIER_FEE, 'ZIAX' ROLE_TOT_TO_PAY,
                                       'ZIAY' FINE_AMOUNT, 'ZIRA' ROAD_TAX, 'ZIRB' ROAD_TAX_PAID, 'ZIRC' TOTAL_TAX_DUE,
                                       'ZIRD' SANCTION, 'ZIRE' NOTIFICATIONS, 'ZIRF' INTEREST, 'ZIRG' ROAD_TAX_TOT_PAY,
                                       'ZIRH' ROAD_TAX_CONTR_PAY ) ) ;
Thanks
Stefano

I attach the explain plan,
of the select Suggested by RaminHashimzadeh
you can optimize?
| Id  | Operation                                      | Name                         | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     | Pstart| Pstop |    TQ  |IN-OUT| PQ Distrib |
|   0 | SELECT STATEMENT                               |                              |    55 | 57090 |       |  3380   (2)| 00:00:48 |       |       |        |      |            |
|   1 |  TEMP TABLE TRANSFORMATION                     |                              |       |       |       |            |          |       |       |        |      |            |
|   2 |   LOAD AS SELECT                               | SYS_TEMP_0FD9D673E_F303A87C  |       |       |       |            |          |       |       |        |      |            |
|   3 |    VIEW                                        |                              |    11 |  4741 |       |    21   (5)| 00:00:01 |       |       |        |      |            |
|   4 |     UNION-ALL                                  |                              |       |       |       |            |          |       |       |        |      |            |
|*  5 |      VIEW                                      |                              |    10 |  4440 |       |    19   (6)| 00:00:01 |       |       |        |      |            |
|*  6 |       WINDOW SORT PUSHED RANK                  |                              |    10 |   570 |       |    19   (6)| 00:00:01 |       |       |        |      |            |
|   7 |        MERGE JOIN CARTESIAN                    |                              |    10 |   570 |       |    18   (0)| 00:00:01 |       |       |        |      |            |
|   8 |         INDEX FULL SCAN                        | MT_REPORTING_LOCALIZATION_PK |     1 |     2 |       |     1   (0)| 00:00:01 |       |       |        |      |            |
|   9 |         BUFFER SORT                            |                              |    10 |   550 |       |    18   (6)| 00:00:01 |       |       |        |      |            |
|  10 |          TABLE ACCESS FULL                     | COSM_CONDITION_CLASS         |    10 |   550 |       |    17   (0)| 00:00:01 |       |       |        |      |            |
|  11 |      FAST DUAL                                 |                              |     1 |       |       |     2   (0)| 00:00:01 |       |       |        |      |            |
|  12 |   PX COORDINATOR                               |                              |       |       |       |            |          |       |       |        |      |            |
|  13 |    PX SEND QC (RANDOM)                         | :TQ10003                     |    55 |  9845 |       |    38   (3)| 00:00:01 |       |       |  Q1,03 | P->S | QC (RAND)  |
|  14 |     LOAD AS SELECT                             | SYS_TEMP_0FD9D673F_F303A87C  |       |       |       |            |          |       |       |  Q1,03 | PCWP |            |
|  15 |      VIEW                                      |                              |    55 |  9845 |       |    38   (3)| 00:00:01 |       |       |  Q1,03 | PCWP |            |
|  16 |       UNION-ALL                                |                              |       |       |       |            |          |       |       |  Q1,03 | PCWP |            |
|* 17 |        VIEW                                    |                              |    54 | 10368 |       |    36   (3)| 00:00:01 |       |       |  Q1,03 | PCWP |            |
|* 18 |         WINDOW SORT PUSHED RANK                |                              |    54 |  3240 |       |    36   (3)| 00:00:01 |       |       |  Q1,03 | PCWP |            |
|  19 |          PX RECEIVE                            |                              |    54 |  3240 |       |    36   (3)| 00:00:01 |       |       |  Q1,03 | PCWP |            |
|  20 |           PX SEND HASH                         | :TQ10002                     |    54 |  3240 |       |    36   (3)| 00:00:01 |       |       |  Q1,02 | P->P | HASH       |
|* 21 |            WINDOW CHILD PUSHED RANK            |                              |    54 |  3240 |       |    36   (3)| 00:00:01 |       |       |  Q1,02 | PCWP |            |
|  22 |             MERGE JOIN CARTESIAN               |                              |    54 |  3240 |       |    35   (0)| 00:00:01 |       |       |  Q1,02 | PCWP |            |
|  23 |              BUFFER SORT                       |                              |       |       |       |            |          |       |       |  Q1,02 | PCWC |            |
|  24 |               PX RECEIVE                       |                              |     1 |     2 |       |     1   (0)| 00:00:01 |       |       |  Q1,02 | PCWP |            |
|  25 |                PX SEND BROADCAST               | :TQ10000                     |     1 |     2 |       |     1   (0)| 00:00:01 |       |       |        | S->P | BROADCAST  |
|  26 |                 INDEX FULL SCAN                | MT_REPORTING_LOCALIZATION_PK |     1 |     2 |       |     1   (0)| 00:00:01 |       |       |        |      |            |
|  27 |              BUFFER SORT                       |                              |    54 |  3132 |       |    35   (3)| 00:00:01 |       |       |  Q1,02 | PCWP |            |
|  28 |               PX BLOCK ITERATOR                |                              |    54 |  3132 |       |    33   (0)| 00:00:01 |       |       |  Q1,02 | PCWC |            |
|  29 |                TABLE ACCESS FULL               | COSM_CONDITION_METHOD        |    54 |  3132 |       |    33   (0)| 00:00:01 |       |       |  Q1,02 | PCWP |            |
|  30 |        BUFFER SORT                             |                              |       |       |       |            |          |       |       |  Q1,03 | PCWC |            |
|  31 |         PX RECEIVE                             |                              |     1 |       |       |     2   (0)| 00:00:01 |       |       |  Q1,03 | PCWP |            |
|  32 |          PX SEND ROUND-ROBIN                   | :TQ10001                     |     1 |       |       |     2   (0)| 00:00:01 |       |       |        | S->P | RND-ROBIN  |
|  33 |           FAST DUAL                            |                              |     1 |       |       |     2   (0)| 00:00:01 |       |       |        |      |            |
|  34 |   PX COORDINATOR                               |                              |       |       |       |            |          |       |       |        |      |            |
|  35 |    PX SEND QC (RANDOM)                         | :TQ20003                     |  1480 |   835K|       |    32   (4)| 00:00:01 |       |       |  Q2,03 | P->S | QC (RAND)  |
|  36 |     LOAD AS SELECT                             | SYS_TEMP_0FD9D673D_F303A87C  |       |       |       |            |          |       |       |  Q2,03 | PCWP |            |
|  37 |      VIEW                                      |                              |  1480 |   835K|       |    32   (4)| 00:00:01 |       |       |  Q2,03 | PCWP |            |
|  38 |       UNION-ALL                                |                              |       |       |       |            |          |       |       |  Q2,03 | PCWP |            |
|* 39 |        VIEW                                    |                              |  1479 |   853K|       |    30   (4)| 00:00:01 |       |       |  Q2,03 | PCWP |            |
|* 40 |         WINDOW SORT PUSHED RANK                |                              |  1479 |   102K|       |    30   (4)| 00:00:01 |       |       |  Q2,03 | PCWP |            |
|  41 |          PX RECEIVE                            |                              |  1479 |   102K|       |    30   (4)| 00:00:01 |       |       |  Q2,03 | PCWP |            |
|  42 |           PX SEND HASH                         | :TQ20002                     |  1479 |   102K|       |    30   (4)| 00:00:01 |       |       |  Q2,02 | P->P | HASH       |
|* 43 |            WINDOW CHILD PUSHED RANK            |                              |  1479 |   102K|       |    30   (4)| 00:00:01 |       |       |  Q2,02 | PCWP |            |
|  44 |             MERGE JOIN CARTESIAN               |                              |  1479 |   102K|       |    29   (0)| 00:00:01 |       |       |  Q2,02 | PCWP |            |
|  45 |              BUFFER SORT                       |                              |       |       |       |            |          |       |       |  Q2,02 | PCWC |            |
|  46 |               PX RECEIVE                       |                              |     1 |     2 |       |     1   (0)| 00:00:01 |       |       |  Q2,02 | PCWP |            |
|  47 |                PX SEND BROADCAST               | :TQ20000                     |     1 |     2 |       |     1   (0)| 00:00:01 |       |       |        | S->P | BROADCAST  |
|  48 |                 INDEX FULL SCAN                | MT_REPORTING_LOCALIZATION_PK |     1 |     2 |       |     1   (0)| 00:00:01 |       |       |        |      |            |
|  49 |              BUFFER SORT                       |                              |  1479 |    99K|       |    29   (4)| 00:00:01 |       |       |  Q2,02 | PCWP |            |
|  50 |               PX BLOCK ITERATOR                |                              |  1479 |    99K|       |    26   (0)| 00:00:01 |       |       |  Q2,02 | PCWC |            |
|  51 |                TABLE ACCESS FULL               | COSM_ORDER_CONDITION_DE      |  1479 |    99K|       |    26   (0)| 00:00:01 |       |       |  Q2,02 | PCWP |            |
|  52 |        BUFFER SORT                             |                              |       |       |       |            |          |       |       |  Q2,03 | PCWC |            |
|  53 |         PX RECEIVE                             |                              |     1 |       |       |     2   (0)| 00:00:01 |       |       |  Q2,03 | PCWP |            |
|  54 |          PX SEND ROUND-ROBIN                   | :TQ20001                     |     1 |       |       |     2   (0)| 00:00:01 |       |       |        | S->P | RND-ROBIN  |
|  55 |           FAST DUAL                            |                              |     1 |       |       |     2   (0)| 00:00:01 |       |       |        |      |            |
|  56 |   PX COORDINATOR                               |                              |       |       |       |            |          |       |       |        |      |            |
|  57 |    PX SEND QC (RANDOM)                         | :TQ30009                     |    55 | 57090 |       |  3380   (2)| 00:00:48 |       |       |  Q3,09 | P->S | QC (RAND)  |
|  58 |     VIEW                                       |                              |    55 | 57090 |       |  3380   (2)| 00:00:48 |       |       |  Q3,09 | PCWP |            |
|* 59 |      FILTER                                    |                              |       |       |       |            |          |       |       |  Q3,09 | PCWC |            |
|  60 |       TRANSPOSE                                |                              |       |       |       |            |          |       |       |  Q3,09 | PCWC |            |
|  61 |        SORT GROUP BY                           |                              |    55 |  5115 |       |  3380   (2)| 00:00:48 |       |       |  Q3,09 | PCWP |            |
|  62 |         PX RECEIVE                             |                              |    55 |  5115 |       |  3380   (2)| 00:00:48 |       |       |  Q3,09 | PCWP |            |
|  63 |          PX SEND HASH                          | :TQ30008                     |    55 |  5115 |       |  3380   (2)| 00:00:48 |       |       |  Q3,08 | P->P | HASH       |
|  64 |           SORT GROUP BY PIVOT                  |                              |    55 |  5115 |       |  3380   (2)| 00:00:48 |       |       |  Q3,08 | PCWP |            |
|* 65 |            VIEW                                |                              |  7757 |   704K|       |  3379   (2)| 00:00:48 |       |       |  Q3,08 | PCWP |            |
|* 66 |             WINDOW SORT PUSHED RANK            |                              |  7757 |  2386K|  2560K|  3379   (2)| 00:00:48 |       |       |  Q3,08 | PCWP |            |
|  67 |              PX RECEIVE                        |                              |  7757 |  2386K|       |  3379   (2)| 00:00:48 |       |       |  Q3,08 | PCWP |            |
|  68 |               PX SEND HASH                     | :TQ30007                     |  7757 |  2386K|       |  3379   (2)| 00:00:48 |       |       |  Q3,07 | P->P | HASH       |
|* 69 |                WINDOW CHILD PUSHED RANK        |                              |  7757 |  2386K|       |  3379   (2)| 00:00:48 |       |       |  Q3,07 | PCWP |            |
|* 70 |                 HASH JOIN RIGHT OUTER          |                              |  7757 |  2386K|       |  3377   (2)| 00:00:48 |       |       |  Q3,07 | PCWP |            |
|  71 |                  PX RECEIVE                    |                              |  1480 | 28120 |       |    43   (3)| 00:00:01 |       |       |  Q3,07 | PCWP |            |
|  72 |                   PX SEND BROADCAST            | :TQ30005                     |  1480 | 28120 |       |    43   (3)| 00:00:01 |       |       |  Q3,05 | P->P | BROADCAST  |
|  73 |                    VIEW                        | COSM_ORDER_CONDITION_DE_L    |  1480 | 28120 |       |    43   (3)| 00:00:01 |       |       |  Q3,05 | PCWP |            |
|  74 |                     VIEW                       |                              |  1480 | 28120 |       |    11   (0)| 00:00:01 |       |       |  Q3,05 | PCWP |            |
|  75 |                      PX BLOCK ITERATOR         |                              |  1480 |   835K|       |    11   (0)| 00:00:01 |       |       |  Q3,05 | PCWC |            |
|  76 |                       TABLE ACCESS FULL        | SYS_TEMP_0FD9D673D_F303A87C  |  1480 |   835K|       |    11   (0)| 00:00:01 |       |       |  Q3,05 | PCWP |            |
|* 77 |                  HASH JOIN                     |                              |  4098 |  1184K|       |  3334   (2)| 00:00:47 |       |       |  Q3,07 | PCWP |            |
|  78 |                   BUFFER SORT                  |                              |       |       |       |            |          |       |       |  Q3,07 | PCWC |            |
|  79 |                    PX RECEIVE                  |                              | 22296 |   718K|       |    47   (0)| 00:00:01 |       |       |  Q3,07 | PCWP |            |
|  80 |                     PX SEND HASH               | :TQ30002                     | 22296 |   718K|       |    47   (0)| 00:00:01 |       |       |        | S->P | HASH       |
|  81 |                      PARTITION HASH ALL        |                              | 22296 |   718K|       |    47   (0)| 00:00:01 |     1 |     4 |        |      |            |
|  82 |                       INDEX FAST FULL SCAN     | SRST_SERVICE_ORDER_ITEM_PK   | 22296 |   718K|       |    47   (0)| 00:00:01 |     1 |     4 |        |      |            |
|  83 |                   PX RECEIVE                   |                              |  4098 |  1052K|       |  3286   (2)| 00:00:47 |       |       |  Q3,07 | PCWP |            |
|  84 |                    PX SEND HASH                | :TQ30006                     |  4098 |  1052K|       |  3286   (2)| 00:00:47 |       |       |  Q3,06 | P->P | HASH       |
|* 85 |                     HASH JOIN                  |                              |  4098 |  1052K|       |  3286   (2)| 00:00:47 |       |       |  Q3,06 | PCWP |            |
|  86 |                      PX RECEIVE                |                              |  3992 |   612K|       |  1757   (2)| 00:00:25 |       |       |  Q3,06 | PCWP |            |
|  87 |                       PX SEND BROADCAST        | :TQ30004                     |  3992 |   612K|       |  1757   (2)| 00:00:25 |       |       |  Q3,04 | P->P | BROADCAST  |
|* 88 |                        HASH JOIN RIGHT OUTER   |                              |  3992 |   612K|       |  1757   (2)| 00:00:25 |       |       |  Q3,04 | PCWP |            |
|  89 |                         PX RECEIVE             |                              |    55 |   330 |       |    40   (3)| 00:00:01 |       |       |  Q3,04 | PCWP |            |
|  90 |                          PX SEND BROADCAST     | :TQ30003                     |    55 |   330 |       |    40   (3)| 00:00:01 |       |       |  Q3,03 | P->P | BROADCAST  |
|  91 |                           VIEW                 | COSM_CONDITION_METHOD_L      |    55 |   330 |       |    40   (3)| 00:00:01 |       |       |  Q3,03 | PCWP |            |
|  92 |                            VIEW                |                              |    55 |   330 |       |     2   (0)| 00:00:01 |       |       |  Q3,03 | PCWP |            |
|  93 |                             PX BLOCK ITERATOR  |                              |    55 |  9845 |       |     2   (0)| 00:00:01 |       |       |  Q3,03 | PCWC |            |
|  94 |                              TABLE ACCESS FULL | SYS_TEMP_0FD9D673F_F303A87C  |    55 |  9845 |       |     2   (0)| 00:00:01 |       |       |  Q3,03 | PCWP |            |
|* 95 |                         HASH JOIN RIGHT OUTER  |                              |  3992 |   588K|       |  1717   (2)| 00:00:25 |       |       |  Q3,04 | PCWP |            |
|  96 |                          BUFFER SORT           |                              |       |       |       |            |          |       |       |  Q3,04 | PCWC |            |
|  97 |                           PX RECEIVE           |                              |    11 |    33 |       |    23   (5)| 00:00:01 |       |       |  Q3,04 | PCWP |            |
|  98 |                            PX SEND BROADCAST   | :TQ30000                     |    11 |    33 |       |    23   (5)| 00:00:01 |       |       |        | S->P | BROADCAST  |
|  99 |                             VIEW               | COSM_CONDITION_CLASS_L       |    11 |    33 |       |    23   (5)| 00:00:01 |       |       |        |      |            |
| 100 |                              VIEW              |                              |    11 |    33 |       |     2   (0)| 00:00:01 |       |       |        |      |            |
| 101 |                               TABLE ACCESS FULL| SYS_TEMP_0FD9D673E_F303A87C  |    11 |  4741 |       |     2   (0)| 00:00:01 |       |       |        |      |            |
|*102 |                          HASH JOIN             |                              |  3992 |   576K|       |  1693   (2)| 00:00:24 |       |       |  Q3,04 | PCWP |            |
| 103 |                           BUFFER SORT          |                              |       |       |       |            |          |       |       |  Q3,04 | PCWC |            |
| 104 |                            PX RECEIVE          |                              |     1 |    49 |       |     1   (0)| 00:00:01 |       |       |  Q3,04 | PCWP |            |
| 105 |                             PX SEND BROADCAST  | :TQ30001                     |     1 |    49 |       |     1   (0)| 00:00:01 |       |       |        | S->P | BROADCAST  |
|*106 |                              INDEX RANGE SCAN  | MT_SETUP_PARAMETERS_PK       |     1 |    49 |       |     1   (0)| 00:00:01 |       |       |        |      |            |
| 107 |                           PX BLOCK ITERATOR    |                              |  1560K|   147M|       |  1688   (2)| 00:00:24 |     1 |     4 |  Q3,04 | PCWC |            |
|*108 |                            TABLE ACCESS FULL   | COPE_ORDER_CONDITION         |  1560K|   147M|       |  1688   (2)| 00:00:24 |     1 |1048575|  Q3,04 | PCWP |            |
| 109 |                      PX BLOCK ITERATOR         |                              |  1560K|   157M|       |  1525   (1)| 00:00:22 |     1 |     4 |  Q3,06 | PCWC |            |
| 110 |                       TABLE ACCESS FULL        | QTST_CONTRACT_PRICE_COND     |  1560K|   157M|       |  1525   (1)| 00:00:22 |     1 |     4 |  Q3,06 | PCWP |            |

Similar Messages

  • I am trying to create a multi provider ? how to optimize my query performan

    hi,
    I am trying to creating a multi provider using four ods ? can anyone let me know how to optimize my query performance. Since my query takes a lot of time to get executed.
    If anyone has any docs for query optimization that is built based on multi provider pls do send it to my email id [email protected]
    regds
    haritha

    hi wond,
    Thanxs a lot for the quick response. Can you let me know how to create secondary indexes on ods and about partioning to be carried out.
    if u have any docs or url can you pls share. my email id [email protected]
    regds
    haritha

  • How to optimize the query

    Hi,
    This below query is taking more than 1hour. So I want to optimize this query.Any suggestion is appriciated.
    In Table customer_details total number of records are 40,000. Among which custno with id='J' are 7000.
    select distinct(A.custno)
    from
    (select distinct custno,id,
    case
    when id='I'
    then 0
    else 1
    end as myid from customer_details where custno not in
    (select custno from customer_details where id='J'))A
    group by A.custno
    having sum(A.myid)>0

    Why instead of
                  from   customer_details
                 where   custno not in (select   custno
                                          from   customer_details
                                         where   id = 'J')
    ...not simply
                  from   customer_details
                 where   custno != 'J'
    ...?

  • How to optimize this query?

    Hi,
    I have this query:
    UPDATE t1
    SET update_date = SYSDATE
    WHERE (col1, col2, col3, col4, col5, col6)
    IN (Some SELECT statement that uses GROUP BY)
    My issue is that table t1 has a full scan on it. It is big and does not have index on update_date column. Is there anyway to accelerate this query?
    Thanks!

    It is 10g and I am not concerned what is happening in the IN clause..
    Plan
    UPDATE STATEMENT ALL_ROWSCost: 15,604 Bytes: 216 Cardinality: 1                               
         8 UPDATE t1                         
              7 HASH JOIN RIGHT SEMI Cost: 15,604 Bytes: 216 Cardinality: 1                     
                   5 VIEW VIEW SYS.VW_NSO_1 Cost: 4,940 Bytes: 167 Cardinality: 1                
                        4 SORT GROUP BY Cost: 4,940 Bytes: 212 Cardinality: 1           
                             3 HASH JOIN Cost: 4,939 Bytes: 212 Cardinality: 1      
                                  1 TABLE ACCESS FULL TABLE t2 Cost: 3 Bytes: 171 Cardinality: 1
                                  2 INDEX FAST FULL SCAN INDEX (UNIQUE) XPKt1 Cost: 4,918 Bytes: 118,869,250 Cardinality: 2,899,250
                   6 TABLE ACCESS FULL TABLE t1 Cost: 10,646 Bytes: 142,063,250 Cardinality: 2,899,250

  • How to optimize this query? Please help

    i have one table(argus) having 80,000 rows and another table (p0f) having 30,000 rows and i have to join both table on the basis of time field. the query is as follows
    select distinct(start_time),res.port, res.dst_port from (select * from argus where argus.start_time between '2007-06-13 19:00:00' and '2007-06-22 20:00:00') res left outer join p0f on res.start_time=p0f.p0f_timestamp ;
    the query is taking very large time . i have created index on the start_time and p0f_timestamp ,it increased the performance but not so much. My date comparisons would vary every time i have to execute a new query.
    Plz tell me is there another way to execute such a query to output same results?
    plz help me as my records are increasing day by day
    Thanks
    Shaveta

    From my small testcase it seems that both queries are absolute identical and don't actually take too much time:
    SQL> create table argus as (select created start_time, object_id port, object_id dst_port from all_objects union all
      2                         select created start_time, object_id port, object_id dst_port from all_objects)
      3  /
    Table created.
    SQL> create table p0f as select created p0f_timestamp, object_id p0f_port, object_id p0f_dst_port from all_objects
      2  /
    Table created.
    SQL> create index argus_idx on argus (start_time)
      2  /
    Index created.
    SQL> create index p0f_idx on p0f (p0f_timestamp)
      2  /
    Index created.
    SQL>
    SQL> begin
      2   dbms_stats.gather_table_stats(user,'argus',cascade=>true);
      3   dbms_stats.gather_table_stats(user,'p0f',cascade=>true);
      4  end;
      5  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select count(*) from argus
      2  /
      COUNT(*)
         94880
    SQL> select count(*) from p0f
      2  /
      COUNT(*)
         47441
    SQL>
    SQL> set timing on
    SQL> set autotrace traceonly explain statistics
    SQL>
    SQL> select distinct (start_time), res.port, res.dst_port
      2             from (select *
      3                     from argus
      4                    where argus.start_time between to_date('2007-06-13 19:00:00','RRRR-MM-DD HH24:MI:SS')
      5                                               and to_date('2007-06-22 20:00:00','RRRR-MM-DD HH24:MI:SS')) res
      6                  left outer join
      7                  p0f on res.start_time = p0f.p0f_timestamp
      8                  ;
    246 rows selected.
    Elapsed: 00:00:02.51
    Execution Plan
    Plan hash value: 1442901002
    | Id  | Operation               | Name    | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT        |         | 21313 |   520K|       |   250   (6)| 00:00:04 |
    |   1 |  HASH UNIQUE            |         | 21313 |   520K|  1352K|   250   (6)| 00:00:04 |
    |*  2 |   FILTER                |         |       |       |       |            |          |
    |*  3 |    HASH JOIN RIGHT OUTER|         | 21313 |   520K|       |    91  (11)| 00:00:02 |
    |*  4 |     INDEX RANGE SCAN    | P0F_IDX |  3661 | 29288 |       |    11   (0)| 00:00:01 |
    |*  5 |     TABLE ACCESS FULL   | ARGUS   |  7325 |   121K|       |    79  (12)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter(TO_DATE('2007-06-13 19:00:00','RRRR-MM-DD
                  HH24:MI:SS')<=TO_DATE('2007-06-22 20:00:00','RRRR-MM-DD HH24:MI:SS'))
       3 - access("ARGUS"."START_TIME"="P0F"."P0F_TIMESTAMP"(+))
       4 - access("P0F"."P0F_TIMESTAMP"(+)>=TO_DATE('2007-06-13 19:00:00','RRRR-MM-DD
                  HH24:MI:SS') AND "P0F"."P0F_TIMESTAMP"(+)<=TO_DATE('2007-06-22
                  20:00:00','RRRR-MM-DD HH24:MI:SS'))
       5 - filter("ARGUS"."START_TIME">=TO_DATE('2007-06-13 19:00:00','RRRR-MM-DD
                  HH24:MI:SS') AND "ARGUS"."START_TIME"<=TO_DATE('2007-06-22 20:00:00','RRRR-MM-DD
                  HH24:MI:SS'))
    Statistics
              1  recursive calls
              0  db block gets
            304  consistent gets
              0  physical reads
              0  redo size
           7354  bytes sent via SQL*Net to client
            557  bytes received via SQL*Net from client
             18  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
            246  rows processed
    SQL>
    SQL> select distinct start_time, port, dst_port
      2             from argus left outer join p0f on start_time = p0f_timestamp
      3            where start_time between to_date ('2007-06-13 19:00:00','RRRR-MM-DD HH24:MI:SS')
      4                                       and to_date ('2007-06-22 20:00:00','RRRR-MM-DD HH24:MI:SS')
      5  /
    246 rows selected.
    Elapsed: 00:00:02.47
    Execution Plan
    Plan hash value: 1442901002
    | Id  | Operation               | Name    | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT        |         | 21313 |   520K|       |   250   (6)| 00:00:04 |
    |   1 |  HASH UNIQUE            |         | 21313 |   520K|  1352K|   250   (6)| 00:00:04 |
    |*  2 |   FILTER                |         |       |       |       |            |          |
    |*  3 |    HASH JOIN RIGHT OUTER|         | 21313 |   520K|       |    91  (11)| 00:00:02 |
    |*  4 |     INDEX RANGE SCAN    | P0F_IDX |  3661 | 29288 |       |    11   (0)| 00:00:01 |
    |*  5 |     TABLE ACCESS FULL   | ARGUS   |  7325 |   121K|       |    79  (12)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter(TO_DATE('2007-06-13 19:00:00','RRRR-MM-DD
                  HH24:MI:SS')<=TO_DATE('2007-06-22 20:00:00','RRRR-MM-DD HH24:MI:SS'))
       3 - access("START_TIME"="P0F_TIMESTAMP"(+))
       4 - access("P0F_TIMESTAMP"(+)>=TO_DATE('2007-06-13 19:00:00','RRRR-MM-DD
                  HH24:MI:SS') AND "P0F_TIMESTAMP"(+)<=TO_DATE('2007-06-22 20:00:00','RRRR-MM-DD
                  HH24:MI:SS'))
       5 - filter("ARGUS"."START_TIME">=TO_DATE('2007-06-13 19:00:00','RRRR-MM-DD
                  HH24:MI:SS') AND "ARGUS"."START_TIME"<=TO_DATE('2007-06-22 20:00:00','RRRR-MM-DD
                  HH24:MI:SS'))
    Statistics
              1  recursive calls
              0  db block gets
            304  consistent gets
              0  physical reads
              0  redo size
           7354  bytes sent via SQL*Net to client
            557  bytes received via SQL*Net from client
             18  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
            246  rows processedCan you show us a similar testcase with explain plan and statistics?

  • How to optimize an aggregate query

    There is a table table1 having more than 3 lacs of records. It has an index on a column say col1. when We issue a simple query select count(col1) from table1, it is taking about 1 minute in exectuion even if index is there. can anyone guide me on how to optimize it

    More information about the problem.
    SQL> select count(r_object_id) from dmi_queue_item_s;
    COUNT(R_OBJECT_ID)
    292784
    SQL> show parameter optimizer
    NAME TYPE VALUE
    optimizer_dynamic_sampling integer 1
    optimizer_features_enable string 9.2.0
    optimizer_index_caching integer 0
    optimizer_index_cost_adj integer 100
    optimizer_max_permutations integer 2000
    optimizer_mode string CHOOSE
    SQL> show parameter db_file_multi
    NAME TYPE VALUE
    db_file_multiblock_read_count integer 16
    SQL> show parameter db_block_size
    NAME TYPE VALUE
    db_block_size integer 8192
    SQL> show parameter cursor_sharing
    NAME TYPE VALUE
    cursor_sharing string EXACT
    SQL> column sname format a20
    SQL> column pname format a20
    SQL> column pval2 format a20
    SQL> select sname,pname,pval1,pval2
    2 from sys.aux_stats$;
    no rows selected
    SQL> explain plan for
    2 select count(r_object_id) from dmi_queue_item_s;
    select count(r_object_id) from dmi_queue_item_s
    ERROR at line 2:
    ORA-02402: PLAN_TABLE not found

  • Can anyone tell me how can i optimize this query...

    Can anyone tell me how can i optimize this query ??? :
    Select Distinct eopersona.numident From rscompeten , rscompet , rscv , eopersona , rscurso , rseduca , rsexplab , rsinteres
    Where ( ( (LOWER (rscompeten.nombre LIKE '%caracas%') AND ( rscompeten.id = rscompet.idcompeten ) AND ( rscv.id = rscompet.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rscurso.nombre) LIKE '%caracas%') AND ( rscv.id = rscurso.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rscurso.lugar) LIKE '%caracas%') AND ( rscv.id = rscurso.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rseduca.univinst) LIKE '%caracas%)' AND ( rscv.id = rseduca.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rsexplab.nombempre) LIKE '%caracas%' AND ( rscv.id = rsexplab.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rsinteres.descrip) LIKE '%caracas%' AND ( rscv.id = rsinteres.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rscv.cargoasp) LIKE '%caracas%' AND ( eopersona.id = rscv.idpersona ) )
    OR ( LOWER (eopersona.ciudad) LIKE '%caracas%' AND ( eopersona.id = rscv.idpersona )
    PLEASE IF YOU FIND SOMETHING WRONG.. PLEASE HELP ME.. this query takes me aproximatelly 10 minutes and the database is really small ( with only 200 records on each table )

    You are querying eight tables, however in any of your OR predicates you're only restricting 3 or 4 of those tables. That means that the remaining 4 or 5 tables are generating cartesian products. (n.b. the cartesian product of 5 tables with 200 rows each results in g 200^5 = 320,000,000,000 rows) Then you casually hide this behind "distinct".
    A simple restatement of your requirements looks like this:
    Select eopersona.numident
      From rscompeten,
           rscompet,
           rscv,
           eopersona
    Where LOWER (rscompeten.nombre) LIKE '%caracas%'
       AND rscompeten.id = rscompet.idcompeten
       AND rscv.id = rscompet.idcv
       AND eopersona.id = rscv.idpersona
    UNION
    Select eopersona.numident
      From rscurso ,
           rscv,
           eopersona
    Where LOWER (rscurso.nombre) LIKE '%caracas%'
       AND rscv.id = rscurso.idcv
       AND eopersona.id = rscv.idpersona
    UNION
    Select eopersona.numident
      From rscurso ,
           rscv,
           eopersona
    Where LOWER (rscurso.lugar) LIKE '%caracas%'
       AND rscv.id = rscurso.idcv
       AND eopersona.id = rscv.idpersona
    UNION
    ...From there you can eliminate redundancies as desired, but I imagine that the above will perform admirably with the data volumes you describe.

  • How does XDB optimize XML Query?

    I found the query speed of XDB is much slower than Berkeley XML DB.
    How does XDB optimize XML Query?
    Are there any documents on this subject?
    And can XDB create indices on XMLType ( e.g. the index on element/attribute value and/or structure index)? if yes, how to do that?

    lezhou had a valid question and asked about:
    "I found the query speed of XDB is much slower than Berkeley XML DB"
    "How does XDB optimize XML Query?"
    These point to a "XML DB Concepts Guide", which does not yet exist.
    The procedures are explained, the methods are explained. If you enable event tracing as described in the XMLDB Developers Guide 10gR2, you will see statements in your trace file which will tell you more about the XML DB architecture (and therefor you can deduct performance impact) then the manual will reveal.
    An other example:
    The xdbconfig.xsd file is neatly explained - in regards of http-port-etc
    But not what the implecations are if you alter one of the other ones (the not explained parameters).
    If you know the architecture (GROUND LEVEL), you can give an correct answer to the initial question "I found the query speed of XDB is much slower than Berkeley XML DB. How does XDB optimize XML Query?"
    The balanced tree index is constructed the same way (on the same theory) in Oracle, DB2, but apparantly X is faster because in with the same buildup/architecture/databasestructure for both products, with the same data, with the same X --> value Y is beter constructed and delivers a better performance.
    apples = apples
    oracle xmldb = berkeley xmldb --> how can i test the o.apples=b.apples and that under these circumstances o.apples are faster ;-)
    THEREFOR:
    "I have to disagree a little bit...("It speaks about all these in detail").
    Still waiting for the XMLDB Concepts Guide / Administrators Guide / Performance Guide.

  • How to optimize xquery expression ?

    hi,
    i got berkeley db xml database with containers: dicom.dbxml and instancemetadata.dbxml.
    dicom.dbxml contains documents as follow:
    <?xml version="1.0" encoding="UTF-8"?>
    <instance docid="dicom_1009">
         <dicom_item>
              <dicom_header>
                   <dicom_tag group="0002" element="0000" vr="UL">194</dicom_tag>
                   <dicom_tag group="0002" element="0001" vr="OB"/>
                   <dicom_tag group="0002" element="0002" vr="UI">1.2.840.10008.5.1.4.1.1.2</dicom_tag>
                   <dicom_tag group="0002" element="0003" vr="UI">2.16.840.1.113662.2.1.4519.41582.4105152.419990505.410523251</dicom_tag>
                   <dicom_tag group="0002" element="0010" vr="UI">1.2.840.10008.1.2.1</dicom_tag>
                   <dicom_tag group="0002" element="0012" vr="UI">2.16.840.1.113662.2.1.1</dicom_tag>
                   <dicom_tag group="0002" element="0016" vr="AE">PHOENIXSCP</dicom_tag>
              </dicom_header>
              <dicom_body>
                   <dicom_tag group="0008" element="0000" vr="UL">596</dicom_tag>
                   <dicom_tag group="0008" element="0005" vr="CS">ISO_IR 100</dicom_tag>
                   <dicom_tag group="0008" element="0008" vr="CS">ORIGINAL\PRIMARY\AXIAL</dicom_tag>
                   <dicom_tag group="0008" element="0012" vr="DA">1999.05.05</dicom_tag>
                   <dicom_tag group="0008" element="0013" vr="TM">10:52:34.530000</dicom_tag>
                   <dicom_tag group="0008" element="0016" vr="UI">1.2.840.10008.5.1.4.1.1.2</dicom_tag>
                   <dicom_tag group="0008" element="0018" vr="UI">2.16.840.1.113662.2.1.4519.41582.4105152.419990505.410523251</dicom_tag>
                   <dicom_tag group="0008" element="0020" vr="DA">1999.05.05</dicom_tag>
                   <dicom_tag group="0008" element="0021" vr="DA">1999.05.05</dicom_tag>
                   <dicom_tag group="0008" element="0022" vr="DA">1999.05.05</dicom_tag>
                   <dicom_tag group="0008" element="0023" vr="DA">1999.05.05</dicom_tag>
                   <dicom_tag group="0008" element="0030" vr="TM">10:52:34.530000</dicom_tag>
                   <dicom_tag group="0008" element="0031" vr="TM">10:52:34.530000</dicom_tag>
                   <dicom_tag group="0008" element="0032" vr="TM">10:52:34.530000</dicom_tag>
                   <dicom_tag group="0008" element="0033" vr="TM">10:52:32.510000</dicom_tag>
                   <dicom_tag group="0008" element="0060" vr="CS">CTTR</dicom_tag>
              </dicom_body>
         </dicom_item>
    </instance>
    instancemetadata.dbxml contains documents as follow:
    <?xml version="1.0" encoding="UTF-8"?>
    <instancemetadata xmlns="imuba.med" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="imuba.med Instancemetadata.xsd">
              <name/>
              <notes/>
              <id>instancemetadata_1</id>
              <instanceid>dicom_1</instanceid>
              <createusername>dd</createusername>
              <createdate>Tue May 02 21:08:06 CEST 2006</createdate>
              <lastmodusername>dd</lastmodusername>
              <lastmoddate>Tue May 02 21:08:06 CEST 2006</lastmoddate>
         </instancemetadata>
    and i got XQuery expression:
    declare namespace n = "imuba.med";
    declare variable $insCont external;
    for $ins in collection(concat(concat("dbxml:containers/", string($insCont)),".dbxml"))/instance,
         $met in collection("dbxml:containers/instancemetadata.dbxml")/n:instancemetadata
    where
    $ins/dicom_item/dicom_body/dicom_tag[@group='0008' and @element='0060'] = "CTTR" and
    $ins/@docid = $met/n:instanceid
    return
    <row>
    { $ins/@docid }
    { $met/n:name }
    { $met/n:notes }
    { $met/n:id }
    { $met/n:instanceid }
         { $met/n:createusername }
    { $met/n:createdate }
    { $met/n:lastmodusername }
    { $met/n:lastmoddate }
    </row>
    while i got 5000 documents in dicom container, the xquery execution time is close to 10 secs. i've tried to create indices using commands:
                        XmlIndexSpecification is = xcDicom.getIndexSpecification();
                        is.addIndex("", "docid", "unique-node-attribute-equality-string");
    and
                        XmlIndexSpecification iss = xcIns.getIndexSpecification();
                        iss.addIndex("imuba.med", "instanceid", "unique-node-element-equality-string");
    And then the execution time is nearly about 7-8 sec, but it's still big (the database contains only 5000 documents).
    Have you any idea how to optimize it ? I suppose the index on element i'm using in the WHERE clause would be helpful (dicom_item/dicom_body/dicom_tag[@group='0008' and @element='0060']). Well, i haven't found concept how to add index on element which can be shown using xpath expression.
    thanks for any help
    Darek

    Hi Darek,
    First off, why not try adding these indexes to see what happens:
    is.addIndex("", "dicom_tag", "node-element-equality-string");
    is.addIndex("", "group", "node-attribute-equality-string");
    is.addIndex("", "element", "node-attribute-equality-string");
    Secondly, what storage model are you using? I would expect you to get better query times using a NodeContainer, with the DBXML_INDEX_NODES flag enabled.
    Thirdly, your "instance" document is not very "XML" like, so you will struggle to get very good query times using that format. If you have control over the format of the document, I would suggest incorporating one or more of the "group", "element", and "vr" attributes into the name of the element - so that you will get multiple elements with different names, instead of one element name with multiple permutations of attributes. Selecting an element by name will always be faster than selecting it by some kind of value.
    Let me know how you get on with these suggestions,
    John

  • How to optmize this query

    How can I optimize this query? it's taking a long time to run
    SELECT A.COL1, B.COL2, C.COL3
    FROM A, B, C
    WHERE A.COL1=B.COL2 (+)
    AND B.COL2=C.COL3 (+)
    Thank you!
    H

    ORA-02393: exceeded call limit on CPU usageContact your dba to increase this resource limit in your profile.
    An other way to write your query :
    select a.col1, null, null
    from a
    where not exists (select null from b where A.COL1=B.COL2)
    union
    select a.col1, b.col2, null
    from a,b
    where A.COL1=B.COL2
    and not exists (select null from c where b.COL1=c.COL2)
    union
    select a.col1, b.col2, c.col3
    from a,b, c
    where A.COL1=B.COL2
    and B.COL2=C.COL3;[pre]
    Nicolas.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Optimization select query...

    Hi..
    The below select query is causing performance issue in production , it is taking much time.
    Please suggest how to optimize it .
    SELECT belnr bukrs gjahr awkey blart FROM bkpf
    INTO TABLE t_bkpf
             WHERE bukrs IN s_bukrs AND
                   gjahr IN r_year.
    Regards
    chetan
    Moderator message - Please see Please Read before Posting in the Performance and Tuning Forum before posting - post locked
    Edited by: Rob Burbank on Oct 13, 2009 10:49 AM

    Hi Chetan,
    I suggest the following to optimize your performance.
    - Change the order of the fields (belnr bukrs gjahr awkey blart), so that they're in the same order than showned in SE11 table data definition (you may need to change the order in t_bkpf definiton also).
    - Add the client in your select statement.
    Something like this:
    SELECT bukrs belnr gjahr blart awkey FROM bkpf CLIENT SPECIFIED
    INTO TABLE t_bkpf
    WHERE mandt = sy-mandt
    AND bukrs IN s_bukrs
    AND gjahr IN r_year.
    Your statement it's very simple. I don't think that there is much more to do.
    Hope that helps.
    Kind regards.
    Edited by: Bruno Garcia on Oct 10, 2009 10:48 AM

  • How to optimize a MDX aggregation functions containing "Exists"?

    I have the following calculated measure:
    sum(([D Player].[Player Name].[All],
    exists([D Match].[Match Id].children,([D Player].[Player Name].currentmember,[Measures].[In Time]),"F Player In Match Stat" ))
    ,[Measures].[Goals])
    Analyzing this calculated measure (the one with "nonempty") in MDX Studio shows "Function
    'Exists' was used inside aggregation function - this disables block computation mode".
    Mosha Pasumansky spoke about this in one of his posts titled "Optimizing
    MDX aggregation functions" where he explains how to optimize MDX aggregation functions containing "Filter",
    "NonEmpty", and "Union", but he said he didn't have time to write about Exists, CrossJoin, Descendants, or EXISTING (he posted this in Oct. 2008 and the busy man didn't have time since that date :P )... so anyone knows an article that continues
    on what Mosha miss or forgot? how to optimize a MDX aggregation function containing "Exists"? what can I do to achieve the same as this calculated measure but in block mode not cell-by-cell mode ?

    Sorry for the late replay.
    I didn't check if your last proposed solution is faster or not, but I'm sorry to say that it gave the wrong result, look at this:
    Player Name
    Players Team
    Goals Player Scored with Team
    A
    Team's Goals in Player's Played Matches
    Lionel Messi
    Argentina
    28
    28
    110
    Lionel Messi
    Barcelona
    341
    330
    978
    The correct result should be like the green column. The last proposed solution in the red column.
    If you look at the query in my first post you will find that the intention is to find the total number of goals a team scored in all matches a player participated in. So in the above example Messi scored 28 goals for Argentina (before the last world cup:)
    )  when the whole Argentinian team scored 110 goals (including Messi's goals) in those matches that Messi played even one minute in.

  • How to find which query taking more cpu

    Hi,
    How to find which query taking more CPU
    at a particular point of time .
    Chhers,

    Take a look at Server Standard Reports. It has a few CPU usage oriented reports.
    You can also track CPU usage by server-side tracing:
    http://www.sqlusa.com/bestpractices/createtrace/
    Glenn Berry's CPU usage query:
    SELECT TOP(25) p.name AS [SP Name], qs.total_worker_time AS [TotalWorkerTime],
    qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.execution_count,
    ISNULL(qs.execution_count/DATEDIFF(Second, qs.cached_time, GETDATE()), 0) AS [Calls/Second],
    qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count
    AS [avg_elapsed_time], qs.cached_time
    FROM sys.procedures AS p WITH (NOLOCK)
    INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK)
    ON p.[object_id] = qs.[object_id]
    WHERE qs.database_id = DB_ID()
    ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE);
    LINK:
    http://dba.stackexchange.com/questions/52216/sql-server-2008-high-cpu-historical-queries
    Query optimization:
    http://www.sqlusa.com/articles/query-optimization/
    Kalman Toth Database & OLAP Architect
    SELECT Video Tutorials 4 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • How do u do Query Caching/Aggregates/Optimise ETL

    Hello
    How do u do the following?A document or step wise approach would be really handy
    1.How do u do Query caching?The pro and cons?How to optimize?
    2.How do u create aggragates?Step by step method?
    3.How do u optimize ETL?Whats the benefits of it?Again a document would be handy
    Thanks

    Search SDN and ASUG for many good presentations.
    Hee's a couple to get you started:
    http://www.asug.com/client_files/Calendar/Upload/ACF3DBF.ppt
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/biw/p-r/performance in sap bw.pdf
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/events/asug-biti-03/sap bw query performance tuning with aggregates

  • Need to optimize a query....

    select AC.ACCT_ID,
    AC.EFF_STR_DT AC_EFF_STR_DT,
    AC.EFF_END_DT AC_EFF_END_DT,
    (select min(CORP_ACCT_ID)
    from D236OT00.GOLD_CUST_CSR_ACC GA
    where (AC.WBS_CD_LEVEL_01 = GA.CORP_ACCT_ID)) CORP_ACCT_ID,
    ASEG.SEGMENT_TYPE,
    ASEG.SEGMENT_CODE,
    AC.WBS_CD_LEVEL_01,
    AC.WBS_CD_LEVEL_02,
    AC.WBS_CD_LEVEL_03,
    AC.WBS_CD_LEVEL_04,
    AC.WBS_CD_LEVEL_05,
    AC.WBS_CD_LEVEL_06,
    AC.WBS_CD_LEVEL_07,
    AC.WBS_CD_LEVEL_08,
    AC.WBS_CD_LEVEL_09,
    AC.WBS_CD_LEVEL_10
    from D236OT00.ACC1_ACCOUNT_NB AC LEFT OUTER JOIN D236OT00.ASEG_ACCT_SEG_NB ASEG
    ON(AC.ACCT_ID = ASEG.ACCT_ID and ASEG.RECORD_EFF_END_DT = '9999-12-31'
    and ASEG.RECORD_EFF_END_TM = '23.59.59'
    and CURRENT DATE between ASEG.EFF_STR_DT and ASEG.EFF_END_DT)
    where AC.ACCT_ID = ? and AC.RECORD_EFF_END_DT = '9999-12-31' and
    AC.EFF_END_DT > CURRENT DATE and AC.INTR_CMPNY_CD in ('PO', 'BO') and
    AC.ACCT_STAT_CD not in ('O', 'V', 'S')
    how can i optimize this query for better performance?

    Try this version
    select AC.ACCT_ID,
    AC.EFF_STR_DT AC_EFF_STR_DT,
    AC.EFF_END_DT AC_EFF_END_DT,
    crop_acct.exp,
    ASEG.SEGMENT_TYPE,
    ASEG.SEGMENT_CODE,
    AC.WBS_CD_LEVEL_01,
    AC.WBS_CD_LEVEL_02,
    AC.WBS_CD_LEVEL_03,
    AC.WBS_CD_LEVEL_04,
    AC.WBS_CD_LEVEL_05,
    AC.WBS_CD_LEVEL_06,
    AC.WBS_CD_LEVEL_07,
    AC.WBS_CD_LEVEL_08,
    AC.WBS_CD_LEVEL_09,
    AC.WBS_CD_LEVEL_10
    from D236OT00.ACC1_ACCOUNT_NB AC,
    D236OT00.ASEG_ACCT_SEG_NB ASEG ,
    (select min(CORP_ACCT_ID) exp
    from D236OT00.GOLD_CUST_CSR_ACC GA
    ) CORP_ACCT,
    where AC.ACCT_ID = ASEG.ACCT_ID
    and ASEG.RECORD_EFF_END_DT = '9999-12-31'
    and ASEG.RECORD_EFF_END_TM = '23.59.59'
    and CURRENTDATE between ASEG.EFF_STR_DT and ASEG.EFF_END_DT
    and AC.ACCT_ID = ?
    and AC.RECORD_EFF_END_DT = '9999-12-31'
    and AC.EFF_END_DT > CURRENTDATE
    and AC.INTR_CMPNY_CD exists ('PO', 'BO')
    and AC.ACCT_STAT_CD not exists ('O', 'V', 'S')
    See if it works

Maybe you are looking for

  • [SOLVED] Xorg & Firefox lock Gnome desktop, causing massive CPU usage

    Hi there, since I have installed ArchLinux x64 on this laptop (Core 2 Duo, 9600M GT with Nvidia's binary driver 195.36.15-2, Gnome 2.30) Xorg spins out of control every so often - more often repeatedly in an hour, sometimes not for a prolonged time.

  • Connection AFW failed, due to: Received HTTP response code 500

    Hi, I have tried to develop a file to file scenario in XI 3.0. The Sendor File adapter is reading the file but the message is not getting transfered to Integration engine. The audit log for the message is as follows: 2005-05-07 04:10:24 Success Chann

  • Slideshow auto run issue?

    I notice that when you create an auto run slideshow, if you include thumbnails or back and forward arrows, once the thumbnails or arrows are used - thus interrupting the auto run - the show does not restart to auto run afterwards and there is no play

  • Images and caption for epub

    Hi, I have a lot of pictures with captions in my ebook and want them to appear together on the same page. My pictures are anchored in the center of the page so are the captions. I tried to group them but still the image and caption appears most of th

  • Which ports are needed for SAP HANA Studio - HANA DB communication?

    I want to connect SAP HANA Studio to a HANA instance. The HANA instance number is 40. The SAP note 1592925 states that the ports 5$$13/5$$14 and 3$$15 should be open to allow communication between the HANA Studio and the HANA database. I even see the