Steps for performance Tuning....!!!!

Hi all,
I need your help in Performance tuning.
While we do tuning in Oracle, apart from Indexes, where clause and order by clause, what are the other points we need to check. I mean explain plan etc...
I am working as Informatica Developer, but i need to make an documents which points out what are the step we can check while doing performance tuning on SQL queries.
Thanks in advance for your help.

Hi,
have a look into these link.it may helpful to you.
When your query takes too long .
When your query takes too long ...
* HOW TO Post a SQL statement tuning request template posting *
HOW TO: Post a SQL statement tuning request - template posting
Edited by: Ravi291283 on Jul 28, 2009 4:00 AM
Edited by: Ravi291283 on Jul 28, 2009 4:01 AM
Edited by: Ravi291283 on Jul 28, 2009 4:02 AM

Similar Messages

  • Can anyone plz tell me the steps for performance tuning.

    hello friends
    what is performance tuning?
    can anyone plz tell me the steps for performance tuning.

    Hi Kishore, this will help u.
    Following are the different tools provided by SAP for performance analysis of an ABAP object
    Run time analysis transaction SE30
    This transaction gives all the analysis of an ABAP program with respect to the database and the non-database processing.
    SQL Trace transaction ST05
    The trace list has many lines that are not related to the SELECT statement in the ABAP program. This is because the execution of any ABAP program requires additional administrative SQL calls. To restrict the list output, use the filter introducing the trace list.
    The trace list contains different SQL statements simultaneously related to the one SELECT statement in the ABAP program. This is because the R/3 Database Interface - a sophisticated component of the R/3 Application Server - maps every Open SQL statement to one or a series of physical database calls and brings it to execution. This mapping, crucial to R/3s performance, depends on the particular call and database system. For example, the SELECT-ENDSELECT loop on the SPFLI table in our test program is mapped to a sequence PREPARE-OPEN-FETCH of physical calls in an Oracle environment.
    The WHERE clause in the trace list's SQL statement is different from the WHERE clause in the ABAP statement. This is because in an R/3 system, a client is a self-contained unit with separate master records and its own set of table data (in commercial, organizational, and technical terms). With ABAP, every Open SQL statement automatically executes within the correct client environment. For this reason, a condition with the actual client code is added to every WHERE clause if a client field is a component of the searched table.
    To see a statement's execution plan, just position the cursor on the PREPARE statement and choose Explain SQL. A detailed explanation of the execution plan depends on the database system in use.
    Need for performance tuning
    In this world of SAP programming, ABAP is the universal language. In most of the projects, the focus is on getting a team of ABAP programmers as soon as possible, handing over the technical specifications to them and asking them to churn out the ABAP programs within the “given deadlines”.
    Often due to this pressure of schedules and deliveries, the main focus of making a efficient program takes a back seat. An efficient ABAP program is one which delivers the required output to the user in a finite time as per the complexity of the program, rather than hearing the comment “I put the program to run, have my lunch and come back to check the results”.
    Leaving aside the hyperbole, a performance optimized ABAP program saves the time of the end user, thus increasing the productivity of the user, and in turn keeping the user and the management happy.
    This tutorial focuses on presenting various performance tuning tips and tricks to make the ABAP programs efficient in doing their work. This tutorial also assumes that the reader is well versed in all the concepts and syntax of ABAP programming.
    Use of selection criteria
    Instead of selecting all the data and doing the processing during the selection, it is advisable to restrict the data to the selection criteria itself, rather than filtering it out using the ABAP code.
    Not recommended
    Select * from zflight.
    Check : zflight-airln = ‘LF’ and zflight-fligh = ‘BW222’.
    Endselect.
    Recommended
    Select * from zflight where airln = ‘LF’ and fligh = ‘222’.
    Endselect.
    One more point to be noted here is of the select *. Often this is a lazy coding practice. When a programmer gives select * even if one or two fields are to be selected, this can significantly slow the program and put unnecessary load on the entire system. When the application server sends this request to the database server, and the database server has to pass on the entire structure for each row back to the application server. This consumes both CPU and networking resources, especially for large structures.
    Thus it is advisable to select only those fields that are needed, so that the database server passes only a small amount of data back.
    Also it is advisable to avoid selecting the data fields into local variables as this also puts unnecessary load on the server. Instead attempt must be made to select the fields into an internal table.
    Use of aggregate functions
    Use the already provided aggregate functions, instead of finding out the minimum/maximum values using ABAP code.
    Not recommended
    Maxnu = 0.
    Select * from zflight where airln = ‘LF’ and cntry = ‘IN’.
    Check zflight-fligh > maxnu.
    Maxnu = zflight-fligh.
    Endselect.
    Recommended
    Select max( fligh ) from zflight into maxnu where airln = ‘LF’ and cntry = ‘IN’.
    The other aggregate functions that can be used are min (to find the minimum value), avg (to find the average of a Data interval), sum (to add up a data interval) and count (counting the lines in a data selection).
    Use of Views instead of base tables
    Many times ABAP programmers deal with base tables and nested selects. Instead it is always advisable to see whether there is any view provided by SAP on those base tables, so that the data can be filtered out directly, rather than specially coding for it.
    Not recommended
    Select * from zcntry where cntry like ‘IN%’.
    Select single * from zflight where cntry = zcntry-cntry and airln = ‘LF’.
    Endselect.
    Recommended
    Select * from zcnfl where cntry like ‘IN%’ and airln = ‘LF’.
    Endselect.
    Check this links
    http://www.sapdevelopment.co.uk/perform/performhome.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/afbad390-0201-0010-daa4-9ef0168d41b6
    kindly reward if found helpful.
    cheers,
    Hema.

  • Step for performance tuning in oracle 10g

    hi,
    i want to know the step of persformance tuning and sql tuning.

    I'd suggest you to refer to documentation: [Oracle Database 2 Day + Performance Tuning Guide 10g Release 2 (10.2)|http://download.oracle.com/docs/cd/B19306_01/server.102/b28051/toc.htm]
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • Steps for performing Flat file to XML

    hey,
    does any one have steps for performing flat file (.csv) to XML conversion. how is the mapping in the design performed.
    kalyan.

    Kalyan,
    Consider my example, I have input file as csv structure and want it to convert into .xml file thats it.
    Input file
    J,24
    P,22
    I want the output file like
    <Emp_Details>
      <F1>J</F1>
      <F2>24</F2>
    </Emp_Details>
    <Emp_Details>
      <F1>P</F1>
      <F2>22</F2>
    </Emp_Details>
    I doesn't know whether the above matches exactly ur reqmt, but there is the option.
    Step 1 : Create Scenario & Business service
    http://www.flickr.com/photo_zoom.gne?id=699386732&size=o
    Step 2: Create sender & receiver comm.channel
    http://www.flickr.com/photo_zoom.gne?id=699386698&size=o
    http://www.flickr.com/photo_zoom.gne?id=699386664&size=o
    Step 3:Create all the objects in ID and cross verify below  whether u've created everything.
    http://www.flickr.com/photo_zoom.gne?id=699386690&size=o
    Step 4: Activate and run the interface.
    Your results :
    http://www.flickr.com/photo_zoom.gne?id=699386686&size=o
    Hope it helps!!!
    Best regards,
    raj.

  • Can anyone send tutor for performance tuning?

    can anyone send tutor for performance tuning?I like to chk my coding.

    1.      Unused/Dead code
    Avoid leaving unused code in the program. Either comment out or delete the unused situation. Use program --> check --> extended program to check for the variables, which are not used statically. 
    2.      Subroutine Usage
    For good modularization, the decision of whether or not to execute a subroutine should be made before the subroutine is called. For example:  
    This is better:
    IF f1 NE 0.
      PERFORM sub1.
    ENDIF. 
    FORM sub1.
    ENDFORM.  
    Than this:
    PERFORM sub1.
    FORM sub1.
      IF f1 NE 0.
      ENDIF.
    ENDFORM. 
    3.      Usage of IF statements
    When coding IF tests, nest the testing conditions so that the outer conditions are those which are most likely to fail. For logical expressions with AND , place the mostly likely false first and for the OR, place the mostly likely true first. 
    Example - nested IF's:
      IF (least likely to be true).
        IF (less likely to be true).
         IF (most likely to be true).
         ENDIF.
        ENDIF.
       ENDIF. 
    Example - IF...ELSEIF...ENDIF :
      IF (most likely to be true).
      ELSEIF (less likely to be true).
      ELSEIF (least likely to be true).
      ENDIF. 
    Example - AND:
       IF (least likely to be true) AND
          (most likely to be true).
       ENDIF.
    Example - OR:
            IF (most likely to be true) OR
          (least likely to be true). 
    4.      CASE vs. nested Ifs
    When testing fields "equal to" something, one can use either the nested IF or the CASE statement. The CASE is better for two reasons. It is easier to read and after about five nested IFs the performance of the CASE is more efficient. 
    5.      MOVE statements
    When records a and b have the exact same structure, it is more efficient to MOVE a TO b than to  MOVE-CORRESPONDING a TO b.
    MOVE BSEG TO *BSEG.
    is better than
    MOVE-CORRESPONDING BSEG TO *BSEG. 
    6.      SELECT and SELECT SINGLE
    When using the SELECT statement, study the key and always provide as much of the left-most part of the key as possible. If the entire key can be qualified, code a SELECT SINGLE not just a SELECT.   If you are only interested in the first row or there is only one row to be returned, using SELECT SINGLE can increase performance by up to three times. 
    7.      Small internal tables vs. complete internal tables
    In general it is better to minimize the number of fields declared in an internal table.  While it may be convenient to declare an internal table using the LIKE command, in most cases, programs will not use all fields in the SAP standard table.
    For example:
    Instead of this:
    data:  t_mara like mara occurs 0 with header line.
    Use this:
    data: begin of t_mara occurs 0,
            matnr like mara-matnr,
            end of t_mara. 
    8.      Row-level processing and SELECT SINGLE
    Similar to the processing of a SELECT-ENDSELECT loop, when calling multiple SELECT-SINGLE commands on a non-buffered table (check Data Dictionary -> Technical Info), you should do the following to improve performance:
    o       Use the SELECT into <itab> to buffer the necessary rows in an internal table, then
    o       sort the rows by the key fields, then
    o       use a READ TABLE WITH KEY ... BINARY SEARCH in place of the SELECT SINGLE command. Note that this only make sense when the table you are buffering is not too large (this decision must be made on a case by case basis).
    9.      READing single records of internal tables
    When reading a single record in an internal table, the READ TABLE WITH KEY is not a direct READ.  This means that if the data is not sorted according to the key, the system must sequentially read the table.   Therefore, you should:
    o       SORT the table
    o       use READ TABLE WITH KEY BINARY SEARCH for better performance. 
    10.  SORTing internal tables
    When SORTing internal tables, specify the fields to SORTed.
    SORT ITAB BY FLD1 FLD2.
    is more efficient than
    SORT ITAB.  
    11.  Number of entries in an internal table
    To find out how many entries are in an internal table use DESCRIBE.
    DESCRIBE TABLE ITAB LINES CNTLNS.
    is more efficient than
    LOOP AT ITAB.
      CNTLNS = CNTLNS + 1.
    ENDLOOP. 
    12.  Performance diagnosis
    To diagnose performance problems, it is recommended to use the SAP transaction SE30, ABAP/4 Runtime Analysis. The utility allows statistical analysis of transactions and programs. 
    13.  Nested SELECTs versus table views
    Since releASE 4.0, OPEN SQL allows both inner and outer table joins.  A nested SELECT loop may be used to accomplish the same concept.  However, the performance of nested SELECT loops is very poor in comparison to a join.  Hence, to improve performance by a factor of 25x and reduce network load, you should either create a view in the data dictionary then use this view to select data, or code the select using a join. 
    14.  If nested SELECTs must be used
    As mentioned previously, performance can be dramatically improved by using views instead of nested SELECTs, however, if this is not possible, then the following example of using an internal table in a nested SELECT can also improve performance by a factor of 5x:
    Use this:
    form select_good.
      data: t_vbak like vbak occurs 0 with header line.
      data: t_vbap like vbap occurs 0 with header line.
      select * from vbak into table t_vbak up to 200 rows.
      select * from vbap
              for all entries in t_vbak
              where vbeln = t_vbak-vbeln.
      endselect.
    endform.
    Instead of this:
    form select_bad.
    select * from vbak up to 200 rows.
      select * from vbap where vbeln = vbak-vbeln.
      endselect.
    endselect.
    endform.
    Although using "SELECT...FOR ALL ENTRIES IN..." is generally very fast, you should be aware of the three pitfalls of using it:
    Firstly, SAP automatically removes any duplicates from the rest of the retrieved records.  Therefore, if you wish to ensure that no qualifying records are discarded, the field list of the inner SELECT must be designed to ensure the retrieved records will contain no duplicates (normally, this would mean including in the list of retrieved fields all of those fields that comprise that table's primary key).
    Secondly,  if you were able to code "SELECT ... FROM <database table> FOR ALL ENTRIES IN TABLE <itab>" and the internal table <itab> is empty, then all rows from <database table> will be retrieved.
    Thirdly, if the internal table supplying the selection criteria (i.e. internal table <itab> in the example "...FOR ALL ENTRIES IN TABLE <itab> ") contains a large number of entries, performance degradation may occur.
    15.  SELECT * versus SELECTing individual fields
    In general, use a SELECT statement specifying a list of fields instead of a SELECT * to reduce network traffic and improve performance.  For tables with only a few fields the improvements may be minor, but many SAP tables contain more than 50 fields when the program needs only a few.  In the latter case, the performace gains can be substantial.  For example:
    Use:
    select vbeln auart vbtyp from table vbak
      into (vbak-vbeln, vbak-auart, vbak-vbtyp)
      where ...
    Instead of using:
    select * from vbak where ... 
    16.  Avoid unnecessary statements
    There are a few cases where one command is better than two.  For example:
    Use:
    append <tab_wa> to <tab>.
    Instead of:
    <tab> = <tab_wa>.
    append <tab> (modify <tab>).
    And also, use:
    if not <tab>[] is initial.
    Instead of:
    describe table <tab> lines <line_counter>.
    if <line_counter> > 0. 
    17.  Copying or appending internal tables
    Use this:
    <tab2>[] = <tab1>[].  (if <tab2> is empty)
    Instead of this:
    loop at <tab1>.
      append <tab1> to <tab2>.
    endloop.
    However, if <tab2> is not empty and should not be overwritten, then use:
    append lines of <tab1> [from index1] [to index2] to <tab2>.
    P.S : Please reward if you find this useful..

  • Resources for performance tuning and RAC needed

    Can you suggest me the best knowledge resources for performance tuning and RAC?
    Besides Oracle doc ...
    Thanks!

    Before all, I'm searching for resources on web like performance tuning from Dizwell Informatics is.
    Anyway thank you Eric for your suggestion!

  • Privilleges for performance tuning

    can we assign any specific privilleges to DBA for the performance tuning.
    i dont want to give sysdba and sysopr privilleges to DBA.

    The question should be why there is need to tune anything in Oracle database. What is the problem, have you defined the problem in a very clear manner ?  Is there anything which is called problem or it is something other one ?  What performance tuning tool you are going to use and why ?
    Performance tuning is only two words, but it is very big topic; a topic on which 100 books / blogs have been written and still writing going on.
    What and why are you trying to tune and what ORA you got ? As such there is no ready made role in oracle which says something like "PT_ROLE".  We just issue the sql to the dictionary objects and as and when we gets privileges related error, we provides select on those sys objects to user; if he really needs though.
    Regards
    Girish Sharma

  • Abap Logic for performance tuning not working when using Internal tables

    Hi,
    I wrote this piece of code that is working correctly that is select SUM of cost from DSO where Plant is the same for Sales Items.
    LOOP AT RESULT_PACKAGE INTO rp.
    SELECT SUM( /N/S_STRDCOST ) FROM /N/ADSP_DPIT00 INTO
    rp-/N/S_STRDCOST
    WHERE /N42/S_SALESITEM = rp-/N42/S_ITEMID AND /N42/S_PLPLANT EQ
    rp-/N42/S_SOURCE.
    MODIFY RESULT_PACKAGE FROM rp.
    Clear rp.
    ENDLOOP.
    Now I try to rewrite it for performance tunning using internal table  but I am getting 0 values. can't figure out whats the problem and been struggling fixing it.
    TYPES : begin of ty_DSO_TABLE,
             /N42/S_STRDCOST TYPE /N/ADSP_DSPC00-/N/S_STRDCOST,
             /N42/S_ITEMID TYPE /N/ADSP_DSPC00-/N/S_ITEMID,
           end of ty_DSO_TABLE.
    DATA: it_DSO_TABLE type hashed table of ty_DSO_TABLE with unique key
    /N/S_ITEMID,
         wa_DSO_TABLE type ty_DSO_TABLE.
    Field-symbols:  <rp> TYPE tys_TG_1.
    LOOP AT RESULT_PACKAGE assigning <rp>.
      clear wa_DSO_TABLE.
    Read table IT_DSO_TABLE into wa_DSO_TABLE with table key /N/S_ITEMID
      = <rp>-/N/S_ITEMID.
      if sy-subrc ne 0.
          select SUM( /N/S_STRDCOST )  into CORRESPONDING
          FIELDS OF wa_DSO_TABLE from
          /N/ADSP_DPIT00 WHERE /N/S_SALESITEM =  <rp>-/N/S_ITEMID AND
          /N/S_PLPLANT EQ <rp>-/N/S_SOURCE.
         if sy-subrc eq 0.
              <rp>-/N/S_STRDCOST = wa_DSO_TABLE-/N/S_STRDCOST.
         endif.
    endif.
    ENDLOOP.
    Any idea whats wrong with the code
    thanks

    Hi Vaidya,
    According to the code which you have written, there is no value in table IT_DSO_TABLE when you are trying to read the values.And after the read statement you have given a condition for sy-subrc. Hence the select statement is actually not even getting executed. *Also you have not assigned the final value back to the ResultPackage.*_
    So Kindly correct your code as follows:
    Data: wa_dso type ty_DSO_TABLE.
    LOOP AT RESULT_PACKAGE assigning <rp>.
    clear wa_DSO_TABLE.
    select SUM( /N/S_STRDCOST ) into CORRESPONDING
    FIELDS OF wa_DSO_TABLE from
    /N/ADSP_DPIT00 WHERE /N/S_SALESITEM = <rp>-/N/S_ITEMID AND
    /N/S_PLPLANT EQ <rp>-/N/S_SOURCE.
    if sy-subrc eq 0.
    <rp>-/N/S_STRDCOST = wa_DSO_TABLE-/N/S_STRDCOST.
    MODIFY RESULT_PACKAGE FROM <rp>.
    endif.
    ENDLOOP.
    Hope this helps you.
    Regards,
    Satyam

  • How to use forms trace file for performance tuning

    I am trying to use forms trace file in order to find cause of forms application performance problem.
    I have read the document B14032-03 where is described how to turn on tracing and how to convert binary trace file to xml or html format. However these xml/html files are useless because they only contain series of forms events, without possibility for grouping or sorting. Actually, they are like to database raw trace file. I need some tool, like tkprof for database trace, that will process xml/html file and generate some more useful format.
    Further, I have tried to load forms trace file into relational database tables in order to use SQL for performance problem investigation. I have followed procedure described in document A92175-01, but without success.
    Is there any way to process xml/html file with grouping, orderering or summing event duration or way to load either binary, xml or html trace file into structured data in database.

    Al-Salamu Alikum user630033
    It's not : elegant at all to thank people 4 No help,it's not their problem that u don't search enough, or u don't have access to db.
    We should always say thank ,or 'Jazak Allah Khiern' on both cases even they could or couldn't help u.
    Finally,i expect ' an appologize or even a thankful word ' and the kindness i am sure u had to publish the solution u found in order to share it with people who had same problem or at least to give them the info to get the appreciation or the thanksful word u deserve.
    Rem.Never give a bad feedback to people who tried to help u.
    Regards,
    Abdetu..

  • Am i doing it correctly for performance tuning ?

    hi guys,
    recently, database cpu usage is high. thus this is the following i do.. ( i am on 10g linux)
    1) do a "top" command in system level
    2) take a few pid
    3) went to v$process and v$session to get the sid of the process.
    4) went to get the sql_id , or prev_sql_id
    5) went to v$sql to get the SQL
    6) at v$sql, check the SQL executed.
    - explain plan for the SQL
    - check the disk_reads, parse call column to see if high .. etc..
    Q1) am i doing it the correct way?
    is there any other things that i must do ? or is there any other short cuts or easier way to find out ?
    like v$session_longops or v$session_Waits ?
    Regards,
    Noob

    user12050668 wrote:
    in your opinion, could you list down a few of the "frequent visit views", when we hit a performance threshold ?Google?
    There's no single definitive site that can answer each and every Oracle performance related problem. When I for example get a session that spins on a specific wait state or event, I will google that.
    There are certain "+silver bullet+" web sites that I will ignore. There are certain sites that I do trust more (having personally dealt with the guys behind it in the past, or knowing them by reputation). But I very seldom skip the googling step and jump directly to a specific blog or website when hitting an Oracle issue that needs some web research.
    There's one exception though. https://support.oracle.com aka Metalink aka My Oracle Support. The support notes on there are not public and therefore not indexed by external search engines. And these notes can often shed light on some interesting problems and issues.
    My advice is do not be afraid to think for yourself. Do not start using "tools" as crutches - use that grey mater you have. It is the result of millions of years of evolution and survival. More flexible than any rigid performance tool. It more than often can do the job when given the proper chance. It can connect dots (see patterns that even advance s/w will be unable to spot), think out of the box, and so on.
    By all means consult the "experts" out there (via web forums, mailing lists, blogs and so on). But realise that very often Oracle version number, o/s kernel and drivers and other factors have a lot of bearing on the technical nature of the problem. And these factors differ and differ a lot in the wild. So what works for some may not for you.
    So think a problem through - understand for example why a wait state occurs and relate it to your problem session's code and SQL. Isolate the problem. And have lots of coffee. ;-)
    A good and complex problem is an invaluable learning experience. Something to enjoy. Perhaps even savour (afterwards). :D

  • Report Slow Due to Mass Data , Soln for Performance Tuning

    Dear All,
    I am making report with mass data so for this i have to put For All enteries in & Ranges at lodz of places.
    1. For all enteries in is making my report works very slow.
    2. If i change for all enteries by Ranges then if the no. of records are large the system will thn
        throw dump.
    If the no. of records are large or the logic applied in complex then report is taking very long
    execution time , Can anyone suggest me the method by which i can optimize my report and make it
    run smoother in performance.
    Thanks
    Ankesh Jindal

    Hi,
    >
    Ankesh Jindal wrote:
    > The problem is with FAE and ranges acc to uptill i have discovered,
    > As I have mentioned if I take FAE and number of records are large the execution will take
    > very large amount of time for that i have changed FAE to ranges but still if no. of records are
    > large in ranges system will throw dump
    >
    so far so good. SQL statements must not get too large.
    >
    Ankesh Jindal wrote:
    > so the best soln for this which i have considered for
    > my reports is to use ranges but with some logic applied that is ;
    >  suppose i have 20,000 records then send data to ranges in 3k or 4k lots .
    > so in this case i am using ranges with 3k or 4k lots so the sytem will not throw dump and i will get
    > faster execution of query with ranges...
    >
    General question: How big is the runtime difference for your SELECT with Range (4k) and the default FAE (5 in case of ORACLE)... more than 20%? could you post your actual run time figures?
    Your range approach is faster because you do less database calls. 5 db calls if you have 4 k entries in the range.
    You can influence the number of database calls as well for the FAE.
    Assuming you are running on ORACLE with a default configuration you have 5 entries per call.
    (Parameters rsdb/max_in_blocking_factor, rsdb/max_blocking_factor). So you will end up
    with 4000 db calls with 5 records each. 
    You compare that with 5 db calls with 4000 records for your range... this is not fair
    Hint your FAE with this, this would lead to 5 db calls for the FAE as well.:
        %_hints oracle '&max_in_blocking_factor 4000&'.
    now compare again... .
    Note1: Be care full with big ranges and blocking factors... cost based optimizers may react sensitive to big inlists or or concatenations and may change plans suddenly... .
    Note2: If you are not on ORACLE your blocking factors may be considerably higher (30, 60, ...).
    Kind regards,
    Hermann

  • Please review procedure for performance tuning

    Hi Friends,
    I have a procedure, which is taking lot of time for execution. Please help me how can i tune this procedure to reduce the execution time.
    Purpose of the procedure : This procedure runs every data to load data from DWH to Data Marts,
    We have some adverse keywords given by business in the table CFG_ADVERSE_KEYWORD ,the procedure will identify the keywords in the tables like df_call_ae_vd, in the notes column and loads only records which has adverse keywords.
    Below is the procedure
    create or replace procedure              LOAD_DM_AE_DATA_PRC
    as
    v_insert_count              NUMBER  := 0;
    /* current_process identifies the block of code where exception is raised, used for debugging */
    v_current_process           VARCHAR2(100) := NULL;
    v_error_code                VARCHAR2(8)   := NULL;
    v_error_text                VARCHAR2(110) := NULL;
    v_error_msg                 VARCHAR2(500) := NULL;
    v_error_count               NUMBER  := 0;
    /* module_name is the procedure name */
    v_module_name               VARCHAR2(50)  := 'LOAD_DM_AE_DATA_PRC';
    /* table_name is the target table truncated and loaded by the procedure */
    v_table_name                 VARCHAR2(50)  := NULL;
    v_table_name1                VARCHAR2(50)  := 'MM_USER_AE_VD';
    v_table_name2                VARCHAR2(50)  := 'MF_CALL_AE_VD';
    v_table_name3                VARCHAR2(50)  := 'MM_CHANGE_REQUEST_AE_VD';
    v_table_name4                VARCHAR2(50)  := 'MM_COMPETITOR_INSIGHT_AE_VD';
    v_table_name5                VARCHAR2(50)  := 'MM_FORMULARY_AE_VD';
    v_table_name6                VARCHAR2(50)  := 'MM_MED_INQUIRY_AE_VD';
    v_table_name7                VARCHAR2(50)  := 'MM_SAMPLETRANS_AE_VD';
    v_table_name8                VARCHAR2(50)  := 'MM_ADVERSE_EVENT_ALL';
    v_table_name9                VARCHAR2(50)  := 'MM_USER_COUNTRY_AE_VD';
    v_table_name10               VARCHAR2(50)  := 'CFG_AE_CONCAT_KEYWORD';
    v_table_name                 VARCHAR2(50)  := NULL;
    /* source_name is the view or source table */
    v_source_name                VARCHAR2(50)  := 'DA_RDW_AP_DWH';
    /* Variables specific to application.  */
    ** Declare Exceptions                                                                          *
    procedure_err              EXCEPTION;
    ** Begin procedure                                                                             *
    BEGIN /* procedure*/
      DBMS_OUTPUT.ENABLE(1000000);
    ** Truncate tables                                                                             *
      BEGIN /* Truncate target*/
        v_current_process := 'Truncate table ' || v_table_name1;
        DBMS_OUTPUT.PUT_LINE(v_current_process);
        EXECUTE IMMEDIATE ('Truncate table ' || v_table_name1);              
        DBMS_OUTPUT.PUT_LINE (v_table_name1||' truncated' ); 
        EXECUTE IMMEDIATE ('Truncate table ' || v_table_name2);              
        DBMS_OUTPUT.PUT_LINE (v_table_name2||' truncated' ); 
        EXECUTE IMMEDIATE ('Truncate table ' || v_table_name3);              
        DBMS_OUTPUT.PUT_LINE (v_table_name3||' truncated' ); 
        EXECUTE IMMEDIATE ('Truncate table ' || v_table_name4);              
        DBMS_OUTPUT.PUT_LINE (v_table_name4||' truncated' ); 
        EXECUTE IMMEDIATE ('Truncate table ' || v_table_name5);              
        DBMS_OUTPUT.PUT_LINE (v_table_name5||' truncated' );
        EXECUTE IMMEDIATE ('Truncate table ' || v_table_name6);              
        DBMS_OUTPUT.PUT_LINE (v_table_name6||' truncated' ); 
        EXECUTE IMMEDIATE ('Truncate table ' || v_table_name7);              
        DBMS_OUTPUT.PUT_LINE (v_table_name7||' truncated' ); 
       EXECUTE IMMEDIATE ('Truncate table ' || v_table_name8);              
        DBMS_OUTPUT.PUT_LINE (v_table_name8||' truncated' ); 
        EXECUTE IMMEDIATE ('Truncate table ' || v_table_name9);              
        DBMS_OUTPUT.PUT_LINE (v_table_name9||' truncated' ); 
        EXECUTE IMMEDIATE ('Truncate table ' || v_table_name10);              
        DBMS_OUTPUT.PUT_LINE (v_table_name10||' truncated' ); 
      EXCEPTION
          WHEN OTHERS THEN
            v_error_count := v_error_count + 1;
            v_error_code  := TO_CHAR(sqlcode);
            v_error_text  := SUBSTR(sqlerrm, 1, 110);
            RAISE procedure_err;
      END; /* Truncate target*/
    ** 1.Load table MM_USER_AE_VD                                                                  *
       BEGIN  
        insert into DM_RDW_AP_VD.MM_USER_AE_VD
        ( ID                     ,
          NAME                   ,
          COUNTRY_CODE_BI__C     ,
          LASTMODIFIEDDATE       ,
          SYSTEMMODSTAMP )
        select
          ID                     ,
          NAME                   ,
          COUNTRY_CODE_BI__C     ,
          LASTMODIFIEDDATE       ,
          sysdate
        from DA_RDW_AP.DM_USER_AE_VD
        union
        select '999', 'Do not delete this record', null, sysdate-1, sysdate-1
        from dual;
        DBMS_OUTPUT.PUT_LINE (v_table_name1||' - '||SQL%ROWCOUNT||' records loaded' ); 
        commit;
       EXCEPTION
          WHEN OTHERS THEN
            v_error_count := v_error_count + 1;
            v_error_code  := TO_CHAR(sqlcode);
            v_error_text  := SUBSTR(sqlerrm, 1, 110);
            RAISE procedure_err;
       END;
    ** 2. SCAN/Load table MF_CALL_AE_VD                                                            *
      BEGIN  
           insert into DM_RDW_AP_VD.MF_CALL_AE_VD
            ( ID                      ,
              NAME                    ,
              CALL_DATE_VOD__C        ,
              PRE_CALL_NOTES_VOD__C   ,
              NEXT_CALL_NOTES_VOD__C  ,
       NEXT_CALL_NOTES_VOD__C_HTML,
              COUNTRY_CODE_BI__C      ,
              OWNERID                 ,
              LASTMODIFIEDDATE        ,
              SYSTEMMODSTAMP)
      select
              distinct a.ID             ,
              a.NAME                    ,
              a.CALL_DATE_VOD__C        ,
              a.PRE_CALL_NOTES_VOD__C   ,
              a.NEXT_CALL_NOTES_VOD__C  ,
       replace(replace(a.NEXT_CALL_NOTES_VOD__C, chr(10),' '),
        substr(replace(a.NEXT_CALL_NOTES_VOD__C, chr(10),' '), instr(replace(replace(lower(a.NEXT_CALL_NOTES_VOD__C), chr(10),' '), chr(13), ''), lower(   trim(b.Keyword)), 1,1), length(trim(b.Keyword))),
                '<FONT style="BACKGROUND-COLOR: yellow"><b>' || substr(replace(a.NEXT_CALL_NOTES_VOD__C, chr(10),' '), instr(replace(replace(lower(a.NEXT_CALL_NOTES_VOD__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))) || '</b></FONT>'
      ) as NEXT_CALL_NOTES_VOD__C_HTML,
              a.COUNTRY_CODE_BI__C      ,
              a.OWNERID                 ,
              a.LASTMODIFIEDDATE        ,
              a.SYSTEMMODSTAMP
          from (da_rdw_ap.df_call_ae_vd a LEFT OUTER JOIN dm_rdw_ap_vd.mm_user_ae_vd c on a.OWNERID=c.ID), dm_rdw_ap_vd.CFG_ADVERSE_KEYWORD b
          --where  (b.country_code = 'EN' and instr( lower(a.NEXT_CALL_NOTES_VOD__C), lower(b.Keyword) , 1, 1 ) > 0)
        where  (b.country_code = 'EN' and instr( lower(' ' || translate(trim(replace(a.NEXT_CALL_NOTES_VOD__C, chr(10),' ')), '().,:;?!', ' ') || ' '), lower(' ' || trim(b.Keyword) || ' ') , 1, 1 ) > 0) and a.NEXT_CALL_NOTES_VOD__C is not null
          union
       select
              distinct a.ID             ,
              a.NAME                    ,
              a.CALL_DATE_VOD__C        ,
              a.PRE_CALL_NOTES_VOD__C   ,
              a.NEXT_CALL_NOTES_VOD__C  ,
       replace(replace(a.NEXT_CALL_NOTES_VOD__C, chr(10),' '),
               substr(replace(a.NEXT_CALL_NOTES_VOD__C, chr(10),' '), instr(replace(replace(lower(a.NEXT_CALL_NOTES_VOD__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))),
                '<FONT style="BACKGROUND-COLOR: yellow"><b>' || substr(replace(a.NEXT_CALL_NOTES_VOD__C, chr(10),' '), instr(replace(replace(lower(a.NEXT_CALL_NOTES_VOD__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))) || '</b></FONT>'
              ) as NEXT_CALL_NOTES_VOD__C_HTML,
              a.COUNTRY_CODE_BI__C      ,
              a.OWNERID                 ,
              a.LASTMODIFIEDDATE        ,
              a.SYSTEMMODSTAMP         
          from (da_rdw_ap.df_call_ae_vd a LEFT OUTER JOIN dm_rdw_ap_vd.mm_user_ae_vd c on a.OWNERID=c.ID LEFT OUTER JOIN
          dm_rdw_ap_vd.CFG_ADVERSE_KEYWORD b on b.country_code = c.COUNTRY_CODE_BI__C)
       --where (instr( lower(a.NEXT_CALL_NOTES_VOD__C), lower(b.Keyword) , 1, 1 ) > 0 );
          where (instr( lower(' ' || translate(trim(replace(a.NEXT_CALL_NOTES_VOD__C, chr(10),' ')), '().,:;?!', ' ') || ' '), lower(' ' || trim(b.Keyword) || ' ') , 1, 1 ) > 0)  and  b.Keyword is not null;
          DBMS_OUTPUT.PUT_LINE (v_table_name2||' - '||SQL%ROWCOUNT||' records loaded' ); 
          commit;
         EXCEPTION
            WHEN OTHERS THEN
              v_error_count := v_error_count + 1;
              v_error_code  := TO_CHAR(sqlcode);
              v_error_text  := SUBSTR(sqlerrm, 1, 110);
              RAISE procedure_err;
      END;
    ** 3. SCAN/Load table MM_CHANGE_REQUEST_AE_VD                                                  *
      BEGIN
        insert into DM_RDW_AP_VD.MM_CHANGE_REQUEST_AE_VD
          (   ID                      ,
              NAME                    ,
              COMMENTS_BI__C          ,
       COMMENTS_BI__C_HTML     ,
              COUNTRY_CODE_BI__C      ,
              OWNERID                 ,
              LASTMODIFIEDDATE        ,
              SYSTEMMODSTAMP )
          select
              distinct a.ID           ,
              a.NAME                  ,
              a.COMMENTS_BI__C        ,
       replace(replace(a.COMMENTS_BI__C, chr(10),' '),
               substr(replace(a.COMMENTS_BI__C, chr(10),' '), instr(replace(replace(lower(a.COMMENTS_BI__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))),
                '<FONT style="BACKGROUND-COLOR: yellow"><b>' || substr(replace(a.COMMENTS_BI__C, chr(10),' '), instr(replace(replace(lower(a.COMMENTS_BI__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))) || '</b></FONT>'
              ) as COMMENTS_BI__C_HTML,
              a.COUNTRY_CODE_BI__C    ,
              a.OWNERID               ,
              a.LASTMODIFIEDDATE      ,
              a.SYSTEMMODSTAMP
          from (DA_RDW_AP.DM_CHANGE_REQUEST_AE_VD a LEFT OUTER JOIN dm_rdw_ap_vd.mm_user_ae_vd c on a.OWNERID=c.ID), dm_rdw_ap_vd.CFG_ADVERSE_KEYWORD b
          --where (b.country_code = 'EN' and instr( lower(a.COMMENTS_BI__C), lower(b.Keyword) , 1, 1 ) > 0) and a.COMMENTS_BI__C  is not null
       where (b.country_code = 'EN' and instr( lower(' ' || translate(trim(replace(a.COMMENTS_BI__C, chr(10),' ')), '().,:;?!', ' ') || ' '), lower(' ' || trim(b.Keyword) || ' ') , 1, 1 ) > 0) and a.COMMENTS_BI__C is not null
          union
          select
              distinct a.ID           ,
              a.NAME                  ,
              a.COMMENTS_BI__C        ,
       replace(replace(a.COMMENTS_BI__C, chr(10),' '),
               substr(replace(a.COMMENTS_BI__C, chr(10),' '), instr(replace(replace(lower(a.COMMENTS_BI__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))),
                '<FONT style="BACKGROUND-COLOR: yellow"><b>' || substr(replace(a.COMMENTS_BI__C, chr(10),' '), instr(replace(replace(lower(a.COMMENTS_BI__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))) || '</b></FONT>'
              ) as COMMENTS_BI__C_HTML,
              a.COUNTRY_CODE_BI__C    ,
              a.OWNERID               ,
              a.LASTMODIFIEDDATE      ,
              a.SYSTEMMODSTAMP
          from (DA_RDW_AP.DM_CHANGE_REQUEST_AE_VD a LEFT OUTER JOIN dm_rdw_ap_vd.mm_user_ae_vd c on a.OWNERID=c.ID LEFT OUTER JOIN
          dm_rdw_ap_vd.CFG_ADVERSE_KEYWORD b on b.country_code = c.COUNTRY_CODE_BI__C)
          --where instr( lower(a.COMMENTS_BI__C), lower(b.Keyword) , 1, 1 ) > 0 and a.COMMENTS_BI__C  is not null;
       where (instr( lower(' ' || translate(trim(replace(a.COMMENTS_BI__C, chr(10),' ')), '().,:;?!', ' ') || ' '), lower(' ' || trim(b.Keyword) || ' ') , 1, 1 ) > 0) and b.Keyword is not null;
          DBMS_OUTPUT.PUT_LINE (v_table_name3||' - '||SQL%ROWCOUNT||' records loaded' ); 
          commit;
      EXCEPTION
          WHEN OTHERS THEN
            v_error_count := v_error_count + 1;
            v_error_code  := TO_CHAR(sqlcode);
            v_error_text  := SUBSTR(sqlerrm, 1, 110);
            RAISE procedure_err;
      END;
    ** 4. SCAN/Load table MM_COMPETITOR_INSIGHT_AE_VD                                              *
      BEGIN
        insert into DM_RDW_AP_VD.MM_COMPETITOR_INSIGHT_AE_VD
         (  COMPETITOR_INSIGHTS_BI__C    ,
      COMPETITOR_INSIGHTS_BI__C_HTML,
            ID                           ,
            NAME                         ,
            OWNERID                      ,
            LASTMODIFIEDDATE             ,
            SYSTEMMODSTAMP )
          select
            distinct a.COMPETITOR_INSIGHTS_BI__C  ,
      replace(replace(a.COMPETITOR_INSIGHTS_BI__C, chr(10),' '),
               substr(replace(a.COMPETITOR_INSIGHTS_BI__C, chr(10),' '), instr(replace(replace(lower(a.COMPETITOR_INSIGHTS_BI__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))),
                '<FONT style="BACKGROUND-COLOR: yellow"><b>' || substr(replace(a.COMPETITOR_INSIGHTS_BI__C, chr(10),' '), instr(replace(replace(lower(a.COMPETITOR_INSIGHTS_BI__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))) || '</b></FONT>'
            ) as COMPETITOR_INSIGHTS_BI__C_HTML,
            a.ID                         ,
            a.NAME                       ,
            a.OWNERID                    ,
            a.LASTMODIFIEDDATE           ,
            a.SYSTEMMODSTAMP
          from (DA_RDW_AP.DM_COMPETITOR_INSIGHT_AE_VD a LEFT OUTER JOIN dm_rdw_ap_vd.mm_user_ae_vd c on a.OWNERID=c.ID), dm_rdw_ap_vd.CFG_ADVERSE_KEYWORD b
          --where (b.country_code = 'EN' and instr( lower(a.COMPETITOR_INSIGHTS_BI__C), lower(b.Keyword) , 1, 1 ) > 0) and a.COMPETITOR_INSIGHTS_BI__C is not null
       where (b.country_code = 'EN' and instr( lower(' ' || translate(trim(replace(a.COMPETITOR_INSIGHTS_BI__C, chr(10),' ')), '().,:;?!', ' ') || ' '), lower(' ' || trim(b.Keyword) || ' ') , 1, 1 ) > 0 ) and a.COMPETITOR_INSIGHTS_BI__C is not null
          union 
          select
            distinct a.COMPETITOR_INSIGHTS_BI__C  ,
      replace(replace(a.COMPETITOR_INSIGHTS_BI__C, chr(10),' '),
             substr(replace(a.COMPETITOR_INSIGHTS_BI__C, chr(10),' '), instr(replace(replace(lower(a.COMPETITOR_INSIGHTS_BI__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))),
                '<FONT style="BACKGROUND-COLOR: yellow"><b>' || substr(replace(a.COMPETITOR_INSIGHTS_BI__C, chr(10),' '), instr(replace(replace(lower(a.COMPETITOR_INSIGHTS_BI__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))) || '</b></FONT>'
            ) as COMPETITOR_INSIGHTS_BI__C_HTML,
            a.ID                         ,
            a.NAME                       ,
            a.OWNERID                    ,
            a.LASTMODIFIEDDATE           ,
            a.SYSTEMMODSTAMP
          from (DA_RDW_AP.DM_COMPETITOR_INSIGHT_AE_VD a LEFT OUTER JOIN dm_rdw_ap_vd.mm_user_ae_vd c on a.OWNERID=c.ID LEFT OUTER JOIN
          dm_rdw_ap_vd.CFG_ADVERSE_KEYWORD b on b.country_code = c.COUNTRY_CODE_BI__C)
          --where instr( lower(a.COMPETITOR_INSIGHTS_BI__C), lower(b.Keyword) , 1, 1 ) > 0 and a.COMPETITOR_INSIGHTS_BI__C is not null;
       where (instr( lower(' ' || translate(trim(replace(a.COMPETITOR_INSIGHTS_BI__C, chr(10),' ')), '().,:;?!', ' ') || ' '), lower(' ' || trim(b.Keyword) || ' ') , 1, 1 ) > 0) and b.Keyword is not null;
          DBMS_OUTPUT.PUT_LINE (v_table_name4||' - '||SQL%ROWCOUNT||' records loaded' ); 
          commit;
      EXCEPTION
          WHEN OTHERS THEN
            v_error_count := v_error_count + 1;
            v_error_code  := TO_CHAR(sqlcode);
            v_error_text  := SUBSTR(sqlerrm, 1, 110);
            RAISE procedure_err;
      END;
    ** 5. SCAN/Load table MM_FORMULARY_AE_VD                                                       *
      BEGIN
         insert into DM_RDW_AP_VD.MM_FORMULARY_AE_VD
          (    COMMENT_FORMULARY_BI__C   ,
        COMMENT_FORMULARY_BI__C_HTML,
               ID                        ,   
               NAME                      ,   
               OWNERID                   ,       
               LASTMODIFIEDDATE          ,
               SYSTEMMODSTAMP )
         select
               distinct  a. COMMENT_FORMULARY_BI__C,
        replace(replace(a.COMMENT_FORMULARY_BI__C, chr(10),' '),
                substr(replace(a.COMMENT_FORMULARY_BI__C, chr(10),' '), instr(replace(replace(lower(a.COMMENT_FORMULARY_BI__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))),
                 '<FONT style="BACKGROUND-COLOR: yellow"><b>' || substr(replace(a.COMMENT_FORMULARY_BI__C, chr(10),' '), instr(replace(replace(lower(a.COMMENT_FORMULARY_BI__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))) || '</b></FONT>'
               ) as COMMENT_FORMULARY_BI__C_HTML,
               a.ID                      ,
               a.NAME                    ,      
               a.OWNERID                 ,    
               a.LASTMODIFIEDDATE        ,
               a.SYSTEMMODSTAMP
          from (DA_RDW_AP.DM_FORMULARY_AE_VD a LEFT OUTER JOIN dm_rdw_ap_vd.mm_user_ae_vd c on a.OWNERID=c.ID), dm_rdw_ap_vd.CFG_ADVERSE_KEYWORD b
          -- where (b.country_code = 'EN' and instr( lower(a.COMMENT_FORMULARY_BI__C), lower(b.Keyword) , 1, 1 ) > 0 and a.COMMENT_FORMULARY_BI__C is not null)
         where (b.country_code = 'EN' and instr( lower(' ' || translate(trim(replace(a.COMMENT_FORMULARY_BI__C , chr(10),' ')), '().,:;?!', ' ') || ' '), lower(' ' || trim(b.Keyword) || ' ') , 1, 1 ) > 0) and a.COMMENT_FORMULARY_BI__C  is not null
          union
          select
               distinct  a. COMMENT_FORMULARY_BI__C,
            replace(replace(a.COMMENT_FORMULARY_BI__C, chr(10),' '),
                substr(replace(a.COMMENT_FORMULARY_BI__C, chr(10),' '), instr(replace(replace(lower(a.COMMENT_FORMULARY_BI__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))),
                 '<FONT style="BACKGROUND-COLOR: yellow"><b>' || substr(replace(a.COMMENT_FORMULARY_BI__C, chr(10),' '), instr(replace(replace(lower(a.COMMENT_FORMULARY_BI__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))) || '</b></FONT>'
               ) as COMMENT_FORMULARY_BI__C_HTML,
               a.ID                      ,
               a.NAME                    ,      
               a.OWNERID                 ,    
               a.LASTMODIFIEDDATE        ,
               a.SYSTEMMODSTAMP
          from (DA_RDW_AP.DM_FORMULARY_AE_VD a LEFT OUTER JOIN dm_rdw_ap_vd.mm_user_ae_vd c on a.OWNERID=c.ID LEFT OUTER JOIN
          dm_rdw_ap_vd.CFG_ADVERSE_KEYWORD b on b.country_code = c.COUNTRY_CODE_BI__C)
          --where (instr( lower(a.COMMENT_FORMULARY_BI__C), lower(b.Keyword) , 1, 1 ) > 0 and a.COMMENT_FORMULARY_BI__C is not null);
       where (instr( lower(' ' || translate(trim(replace(a.COMMENT_FORMULARY_BI__C, chr(10),' ')), '().,:;?!', ' ') || ' '), lower(' ' || trim(b.Keyword) || ' ') , 1, 1) > 0) and b.Keyword is not null;
          DBMS_OUTPUT.PUT_LINE (v_table_name5||' - '||SQL%ROWCOUNT||' records loaded' ); 
          commit;
      EXCEPTION
          WHEN OTHERS THEN
            v_error_count := v_error_count + 1;
            v_error_code  := TO_CHAR(sqlcode);
            v_error_text  := SUBSTR(sqlerrm, 1, 110);
            RAISE procedure_err;
      END;
    ** 6. SCAN/Load table MM_MED_INQUIRY_AE_VD                                                     *
      BEGIN
        insert into DM_RDW_AP_VD.MM_MED_INQUIRY_AE_VD
         (   ID                  ,
             NAME                ,
             INQUIRY_TEXT__C     ,
      INQUIRY_TEXT__C_HTML,
             CREATEDBYID         , 
             LASTMODIFIEDDATE    ,
             SYSTEMMODSTAMP )
           select
             distinct a.ID       ,
             a.NAME              ,
             a.INQUIRY_TEXT__C   ,
      replace(replace(a.INQUIRY_TEXT__C, chr(10),' '),
               substr(replace(a.INQUIRY_TEXT__C, chr(10),' '), instr(replace(replace(lower(a.INQUIRY_TEXT__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)),1,1), length(trim(b.Keyword))),
                '<FONT style="BACKGROUND-COLOR: yellow"><b>' || substr(replace(a.INQUIRY_TEXT__C, chr(10),' '), instr(replace(replace(lower(a.INQUIRY_TEXT__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))) || '</b></FONT>'
             ) as INQUIRY_TEXT__C_HTML,
             a.CREATEDBYID       ,    
             a.LASTMODIFIEDDATE  ,
             a.SYSTEMMODSTAMP
          from (DA_RDW_AP.DM_MED_INQUIRY_AE_VD a LEFT OUTER JOIN dm_rdw_ap_vd.mm_user_ae_vd c on a.CREATEDBYID=c.ID), dm_rdw_ap_vd.CFG_ADVERSE_KEYWORD b
          --where (b.country_code = 'EN' and instr( lower(a.INQUIRY_TEXT__C), lower(b.Keyword) , 1, 1 ) > 0 and a.INQUIRY_TEXT__C is not null)
       where (b.country_code = 'EN' and instr( lower(' ' || translate(trim(replace(a.INQUIRY_TEXT__C, chr(10),' ')), '().,:;?!', ' ') || ' '), lower(' ' || trim(b.Keyword) || ' ') , 1, 1 ) > 0) and a.INQUIRY_TEXT__C  is not null
          union
          select
             distinct a.ID       ,
             a.NAME              ,
             a.INQUIRY_TEXT__C   ,
      replace(replace(a.INQUIRY_TEXT__C, chr(10),' '),
               substr(replace(a.INQUIRY_TEXT__C, chr(10),' '), instr(replace(replace(lower(a.INQUIRY_TEXT__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)),1,1), length(trim(b.Keyword))),
                '<FONT style="BACKGROUND-COLOR: yellow"><b>' || substr(replace(a.INQUIRY_TEXT__C, chr(10),' '), instr(replace(replace(lower(a.INQUIRY_TEXT__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))) || '</b></FONT>'
             ) as INQUIRY_TEXT__C_HTML,
             a.CREATEDBYID       ,    
             a.LASTMODIFIEDDATE  ,
             a.SYSTEMMODSTAMP
          from (DA_RDW_AP.DM_MED_INQUIRY_AE_VD a LEFT OUTER JOIN dm_rdw_ap_vd.mm_user_ae_vd c on a.CREATEDBYID=c.ID LEFT OUTER JOIN
          dm_rdw_ap_vd.CFG_ADVERSE_KEYWORD b on b.country_code = c.COUNTRY_CODE_BI__C)
          --where (instr( lower(a.INQUIRY_TEXT__C), lower(b.Keyword) , 1, 1 ) > 0 and a.INQUIRY_TEXT__C is not null);
          where (instr( lower(' ' || translate(trim(replace(a.INQUIRY_TEXT__C, chr(10),' ')), '().,:;?!', ' ') || ' '), lower(' ' || trim(b.Keyword) || ' ') , 1, 1 ) > 0) and b.Keyword is not null;
          DBMS_OUTPUT.PUT_LINE (v_table_name6||' - '||SQL%ROWCOUNT||' records loaded' ); 
          commit;
      EXCEPTION
          WHEN OTHERS THEN
            v_error_count := v_error_count + 1;
            v_error_code  := TO_CHAR(sqlcode);
            v_error_text  := SUBSTR(sqlerrm, 1, 110);
            RAISE procedure_err;
      END;
    ** 7. SCAN/Load table MM_SAMPLETRANS_AE_VD                                                     *
      BEGIN
        insert into DM_RDW_AP_VD.MM_SAMPLETRANS_AE_VD
         (  COMMENTS_VOD__C     ,
      COMMENTS_VOD__C_HTML,
            ID                  ,
            NAME                ,
            CREATEDBYID         ,
            LASTMODIFIEDDATE    ,
            SYSTEMMODSTAMP)
         select
            distinct  a.COMMENTS_VOD__C   ,
      replace(replace(a.COMMENTS_VOD__C, chr(10),' '),
             substr(replace(a.COMMENTS_VOD__C, chr(10),' '), instr(replace(replace(lower(a.COMMENTS_VOD__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))),
                '<FONT style="BACKGROUND-COLOR: yellow"><b>' || substr(replace(a.COMMENTS_VOD__C, chr(10),' '), instr(replace(replace(lower(a.COMMENTS_VOD__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))) || '</b></FONT>'
            ) as COMMENTS_VOD__C_HTML,
            a.ID                ,
            a.NAME              ,
            a.CREATEDBYID       ,   
            a.LASTMODIFIEDDATE  ,
            a.SYSTEMMODSTAMP
          from (DA_RDW_AP.DM_SAMPLETRANS_AE_VD a LEFT OUTER JOIN dm_rdw_ap_vd.mm_user_ae_vd c on a.CREATEDBYID=c.ID), dm_rdw_ap_vd.CFG_ADVERSE_KEYWORD b
          --where (b.country_code = 'EN' and instr( lower(a.COMMENTS_VOD__C), lower(b.Keyword) , 1, 1 ) > 0 and a.COMMENTS_VOD__C is not null)
       where (b.country_code = 'EN' and instr( lower(' ' || translate(trim(replace(a.COMMENTS_VOD__C , chr(10),' ')), '().,:;?!', ' ') || ' '), lower(' ' || trim(b.Keyword) || ' ') , 1, 1 ) > 0) and a.COMMENTS_VOD__C  is not null
         union
         select
            a.COMMENTS_VOD__C   ,
      replace(replace(a.COMMENTS_VOD__C, chr(10),' '),
             substr(replace(a.COMMENTS_VOD__C, chr(10),' '), instr(replace(replace(lower(a.COMMENTS_VOD__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))),
                '<FONT style="BACKGROUND-COLOR: yellow"><b>' || substr(replace(a.COMMENTS_VOD__C, chr(10),' '), instr(replace(replace(lower(a.COMMENTS_VOD__C), chr(10),' '), chr(13), ''), lower(trim(b.Keyword)), 1,1), length(trim(b.Keyword))) || '</b></FONT>'
            ) as COMMENTS_VOD__C_HTML,
            a.ID                ,
            a.NAME              ,
            a.CREATEDBYID       ,   
            a.LASTMODIFIEDDATE  ,
            a.SYSTEMMODSTAMP
          from (DA_RDW_AP.DM_SAMPLETRANS_AE_VD a LEFT OUTER JOIN dm_rdw_ap_vd.mm_user_ae_vd c on a.CREATEDBYID=c.ID LEFT OUTER JOIN
          dm_rdw_ap_vd.CFG_ADVERSE_KEYWORD b on b.country_code = c.COUNTRY_CODE_BI__C)
          --where instr( lower(a.COMMENTS_VOD__C), lower(b.Keyword) , 1, 1 ) > 0 and a.COMMENTS_VOD__C is not null;
       where (instr( lower(' ' || translate(trim(replace(a.COMMENTS_VOD__C, chr(10),' ')), '().,:;?!', ' ') || ' '), lower(' ' || trim(b.Keyword) || ' ') , 1, 1) > 0) and b.Keyword is not null;
          DBMS_OUTPUT.PUT_LINE (v_table_name7||' - '||SQL%ROWCOUNT||' records loaded' );
          commit;   
      EXCEPTION
          WHEN OTHERS THEN
            v_error_count := v_error_count + 1;
            v_error_code  := TO_CHAR(sqlcode);
            v_error_text  := SUBSTR(sqlerrm, 1, 110);
            RAISE procedure_err;
      END;
    ** 8.Load table MM_ADVERSE_EVENT_ALL                                                                  *
       BEGIN  
        insert into MM_ADVERSE_EVENT_ALL
        ( COUNTRY_CODE_BI__C ,
          CALLDATE         ,
          COMMENTS     ,
       COMMENTS_HTML     ,
          OWNERID       ,
       LASTMODIFIEDDATE ,
       RECORDTYPE ,
       SORT ,
          SYSTEMMODSTAMP )
      select nvl(a.country_code_bi__c, b.country_code_bi__c) as country_code_bi__c,
      a.calldate,
      a.comments,
      a.comments_html,
      a.ownerid,
      a.lastmodifieddate,
      a.recordtype,
      a.sort,
      a.systemmodstamp
      from (select
      country_code_bi__c,
      call_date_vod__c as calldate,
      next_call_notes_vod__c as comments,
      next_call_notes_vod__c_html as comments_html,
      ownerid,
      lastmodifieddate,
      'Call' as recordtype,
      '1' as sort,
      systemmodstamp
      from mf_call_ae_vd
      union
      select
      country_code_bi__c,
      lastmodifieddate as calldate,
      comments_bi__c as comments, 
      comments_bi__c_html as comments_html, 
      ownerid,
      lastmodifieddate,
      'Change Request' as recordtype,
      '2' as sort,
      systemmodstamp
      from mm_change_request_ae_vd
      union
      select
      null,
      lastmodifieddate as calldate,
      competitor_insights_bi__c as comments,
      competitor_insights_bi__c_html as comments_html,
      ownerid,
      lastmodifieddate,
      'Competitor Insight' as recordtype,
      '3' as sort,
      systemmodstamp
      from mm_competitor_insight_ae_vd
      union
      select
      null,
      lastmodifieddate as calldate,
      comment_formulary_bi__c as comments,
      comment_formulary_bi__c_html as comments_html,
      ownerid,
      lastmodifieddate,
      'Formulary' as recordtype,
      '4' as sort,
      systemmodstamp
      from mm_formulary_ae_vd
      union
      select
      null,
      lastmodifieddate as calldate,
      inquiry_text__c as comments,
      inquiry_text__c_html as comments_html,
      createdbyid as ownerid,
      lastmodifieddate,
      'Customer Request' as recordtype,
      '5' as sort,
      systemmodstamp
      from mm_med_inquiry_ae_vd
      union
      select
      null,
      lastmodifieddate as calldate,
      comments_vod__c as comments,
      comments_vod__c_html as comments_html,
      createdbyid as ownerid,
      lastmodifieddate,
      'Sample Transaction' as recordtype,
      '6' as sort,
      systemmodstamp
      from mm_sampletrans_ae_vd
      ) a LEFT OUTER JOIN mm_user_ae_vd b on a.ownerid=b.ID;
        DBMS_OUTPUT.PUT_LINE (v_table_name8||' - '||SQL%ROWCOUNT||' records loaded' ); 
        commit;
       EXCEPTION
          WHEN OTHERS THEN
            v_error_count := v_error_count + 1;
            v_error_code  := TO_CHAR(sqlcode);
            v_error_text  := SUBSTR(sqlerrm, 1, 110);
            RAISE procedure_err;
       END; 
    ** 9.Load table MM_USER_COUNTRY_AE_VD                                                               *
       BEGIN  
        insert into MM_USER_COUNTRY_AE_VD
        ( REGION       ,
          COUNTRY_CODE ,
          COUNTRY_NAME )
      select distinct
      case
      when u.country_code_bi__c in  ('AE','BH','EG','JO','KW','LB','OM','QA','SA') then ('EMEA')
      when u.country_code_bi__c in  ('AU','CN','HK','ID','IN','JP','KR','MY','PH','SG','TH','TW', 'VN') then ('APAC')
      when u.country_code_bi__c in  ('BR','CA','MX','US' ) then ('AMERICA')
          --when u.country_code_bi__c in  ('AU', 'CN','IN','JP','KR','MY', 'TH','TW') then ('APAC')
          --when u.country_code_bi__c in  ('CA','CE','CR','DO','GT','HN','NI','PA','SV','US') then ('AMERICA')
      else (null)
      end as REGION,
      u.country_code_bi__c AS COUNTRY_CODE,
      decode (u.country_code_bi__c,
      'AE', 'United Arab Emirates',
        'BH', 'Bahrain',
      'EG', 'Egypt',
      'JO', 'Jordan',
      'KW', 'Kuwait',
      'LB', 'Lebanon',
      'OM', 'Oman',
      'QA', 'Qatar',
      'SA', 'Saudi Arabia',
        'AU', 'Australia',
      'CN', 'China',
      'HK', 'Hong Kong',
      'ID', 'Indonesia',
      'IN', 'India',
        'JP', 'Japan',
      'KR', 'Korea',
      'MY', 'Malaysia',
      'PH', 'Philippines',
      'SG', 'Singapore',
      'TH', 'Thailand',
      'TW', 'Taiwan',
      'VN', 'Vietnam',
      'BR', 'Brazil',
      'CA', 'Canada',
        'MX', 'Mexico',
        'US', 'United States') AS COUNTRY_NAME
      from DA_RDW_AP.DM_USER_AE_VD u, DA_RDW_AP.DF_CALL_AE_VD c
      where u.id = c.ownerid
      and u.country_code_bi__c is not null
      order by region, country_name;
        DBMS_OUTPUT.PUT_LINE (v_table_name9||' - '||SQL%ROWCOUNT||' records loaded' ); 
        commit;
       EXCEPTION
          WHEN OTHERS THEN
            v_error_count := v_error_count + 1;
            v_error_code  := TO_CHAR(sqlcode);
            v_error_text  := SUBSTR(sqlerrm, 1, 110);
            RAISE procedure_err;
       END;
    ** 10. Load table CFG_AE_CONCAT_KEYWORD - Load concatenated data in a single record by country code *
       BEGIN  
        insert into DM_RDW_AP_VD.CFG_AE_CONCAT_KEYWORD
         (COUNTRY_CODE ,
        KEYWORD)
        select country_code, replace(output, ',', ', ') as keyword
        from
          (select country_code, wm_concat(trim(keyword)) over (partition by country_code order by rownumber) as output,
             count(keyword) over (partition by country_code order by rownumber) as running_count,
             count(keyword) over (partition by country_code) as tot_count
          from DM_RDW_AP_VD.CFG_ADVERSE_KEYWORD)
          where running_count = tot_count;
        DBMS_OUTPUT.PUT_LINE (v_table_name10||' - '||SQL%ROWCOUNT||' records loaded' ); 
        commit;
       EXCEPTION
          WHEN OTHERS THEN
            v_error_count := v_error_count + 1;
            v_error_code  := TO_CHAR(sqlcode);
            v_error_text  := SUBSTR(sqlerrm, 1, 110);
            RAISE procedure_err;
       END;  
    ** Mandatory record for burst query                                                            *
      BEGIN  
           insert into DM_RDW_AP_VD.MF_CALL_AE_VD
            ( ID                      ,
              NAME                    ,
              CALL_DATE_VOD__C        ,
              PRE_CALL_NOTES_VOD__C   ,
              NEXT_CALL_NOTES_VOD__C  ,
              NEXT_CALL_NOTES_VOD__C_HTML,
              COUNTRY_CODE_BI__C      ,
              OWNERID                 ,
              LASTMODIFIEDDATE        ,
              SYSTEMMODSTAMP)
      select
              ID                      ,
              NAME                    ,
              sysdate - 1             ,
              PRE_CALL_NOTES_VOD__C   ,
              NEXT_CALL_NOTES_VOD__C  ,
              NEXT_CALL_NOTES_VOD__C_HTML,
              COUNTRY_CODE_BI__C      ,
              OWNERID                 ,
              sysdate - 1             ,
              sysdate - 1
        from DM_RDW_AP_VD.MF_CALL_AE_VD_DUMMY;
          DBMS_OUTPUT.PUT_LINE (v_table_name2||' - '||SQL%ROWCOUNT||' records loaded' ); 
          commit;
         EXCEPTION
            WHEN OTHERS THEN
              v_error_count := v_error_count + 1;
              v_error_code  := TO_CHAR(sqlcode);
              v_error_text  := SUBSTR(sqlerrm, 1, 110);
              RAISE procedure_err;
      END;
    END LOAD_DM_AE_DATA_PRC;

    In following replace.. replace.. substr what are you trying to achieve? Can you please eg. so that we can try to use regular expression to do what being done by so many replace, substrs... This will help improve code performance and readability!
    ** 2. SCAN/Load table MF_CALL_AE_VD *
              replace(replace(a.NEXT_CALL_NOTES_VOD__C, chr(10), ' '),
                      substr(replace(a.NEXT_CALL_NOTES_VOD__C, chr(10), ' '),
                             instr(replace(replace(lower(a.NEXT_CALL_NOTES_VOD__C),
                                                   chr(10),
                                           chr(13),
                                   lower(trim(b.Keyword)),
                                   1,
                                   1),
                             length(trim(b.Keyword))),
                      '<FONT style="BACKGROUND-COLOR: yellow"><b>' ||
                      substr(replace(a.NEXT_CALL_NOTES_VOD__C, chr(10), ' '),
                             instr(replace(replace(lower(a.NEXT_CALL_NOTES_VOD__C),
                                                   chr(10),
                                           chr(13),
                                   lower(trim(b.Keyword)),
                                   1,
                                   1),
                             length(trim(b.Keyword))) || '</b></FONT>'
                      ) as NEXT_CALL_NOTES_VOD__C_HTML,

  • Query for Performance tuning

    Hi,
    I have attached my query and explain plan for that query. This create statement takes around 1.5 hrs for 200K records.
    Is there any way to tune the query.
    CREATE TABLE SC1.TMP_MP_XYZ
    PARALLEL 4 TABLESPACE FT_WORKAREA NOLOGGING AS
    SELECT /*+ ORDERED USE_HASH(x,d) INDEX_FFS(x) PARALLEL(d,4) */
    d.ROWID dis_rowid
    FROM SC2.TMP_GLOBAL PARTITION (PM200802) x,
    SC1.ba_DISP_XX PARTITION (PM200802) d
    WHERE x.dsp_hash IN
    (d.dsp_hash,
    TRUNC (d.dsp_hash, -14),
    TRUNC (d.dsp_hash, -7),
    TRUNC (d.dsp_hash, -14) + MOD (d.dsp_hash, POWER (10, 7))
    AND LOWER (d.url_name) LIKE x.rule || '%'
    AND BITAND (d.xflag, 1) = 0
    AND BITAND (d.xflag, 1) = 0
    Statement Id=14 Type=TABLE ACCESS
    Cost=17004 TimeStamp=06-03-08::10::04:37
    (1) CREATE TABLE STATEMENT CHOOSE
    Est. Rows: 274 Cost: 68,076
    LOAD AS SELECT
    (14) CONCATENATION
    (4) HASH JOIN
    Est. Rows: 1 Cost: 17,019
    (2) UNIQUE INDEX FAST FULL SCAN SC2.IMP_TMP_GLOBAL__NAME [Not Analyzed]
    Est. Rows: 146,873 Cost: 15
    (3) TABLE ACCESS FULL SC1.BA_DISP_XX [Analyzed]
    Blocks: 2,436 Est. Rows: 32 of 31,951 Cost: 17,004
    (7) HASH JOIN
    Est. Rows: 1 Cost: 17,019
    (5) UNIQUE INDEX FAST FULL SCAN SC2.IMP_TMP_GLOBAL _NAME  [Not Analyzed]
    Est. Rows: 146,873 Cost: 15
    (6) TABLE ACCESS FULL SC1.BA_DISP_XX [Analyzed]
    Blocks: 2,436 Est. Rows: 32 of 31,951 Cost: 17,004
    (10) HASH JOIN
    Est. Rows: 1 Cost: 17,019
    (8) UNIQUE INDEX FAST FULL SCAN SC2.IMP_TMP_GLOBAL__NAME [Not Analyzed]
    Est. Rows: 146,873 Cost: 15
    (9) TABLE ACCESS FULL SC1.BA_DISP_XX [Analyzed]
    Blocks: 2,436 Est. Rows: 32 of 31,951 Cost: 17,004
    (13) HASH JOIN
    Est. Rows: 1 Cost: 17,019
    (11) UNIQUE INDEX FAST FULL SCAN SC2.IMP_TMP_GLOBAL _NAME  [Not Analyzed]
    Est. Rows: 146,873 Cost: 15
    (12) TABLE ACCESS FULL SC1.BA_DISP_XX [Analyzed]
    Blocks: 2,436 Est. Rows: 32 of 31,951 Cost: 17,004
    - Mahesh

    First, can you repost with better formatting. Your execution plan has lost any indentation, and everything is at the same level, which makes it difficult to work out the real order of execution. Put the SQL statement and plan between lines with and on them, but with CODE in lower case i.e. code, which the forum engine recognises.
    Second, you seem to have four full table scans on ba_DISP_XX, which is probably due to the IN clause in the WHERE. I don't know what indexes you have, because you don't mention it. But Oracle cannot use ordinary indexes on columns when you apply a function or expression to that column. Which is what you are doing to the dsp_hash column, with the TRUNC function.
    So, the quickest comments I can make are:
    Investigate using function based indexes, but you may need several of them, which all take up disk space.
    Rewrite the query to not use TRUNC, or to use it in a standard way so that a single function based index could be used.
    Get rid of the hints. You are explicitly telling Oracle to use a HASH join, and PARALLEL scan the ba_DISP_XX table. Which is what it is doing in the execution plan. So you are getting what you have asked for.
    The query is very odd. Where is the proper join between tables x and d? I see an IN between them, which is unlikely to be the join. And a LOWER LIKE. If this is the join, then create a function based index on LOWER (d.url_name). Again, without a suitable index, Oracle will scan the full table.
    Bottom line - the query is doing what you want, because you have used hints to tell it to scan that table and use a HASH join, and without using function based indexes Oracle cannot used ordinary indexes for this query. So it will table scan either way.
    John

  • V$ views for performance tuning

    Hi,
    What are the views used for identifying sessions (top resourced) and to find highly loaded SQL statements ...apart from seeing from AWR report.?

    Hi,
    As you would be on 10g or higher version of the Oracle, you can use dbms_xplan.display_cursor or display_awr function to check the explain plan.Find the sql_id for the particular sql and check the plan
    Read http://download.oracle.com/docs/cd/B13789_01/appdev.101/b10802/d_xplan.htm#998179
    HTH
    Anand
    Edited by: Anand... on Oct 19, 2010 11:27 PM

  • Need clear steps for doing performance tuning on SQL Server 2008 R2 (DB Engine, Reporting Services and Integration Services)

    We have to inverstigate about a reporting solution where things are getting slow (may be material, database design, network matters).
    I have red a lot in MSDN and some books about performance tuning on SQL Server 2008 R2 (or other) but frankly, I feel a little lost in all that stuff
    I'am looking for practical steps in order to do the tuning. Someone had like a recipe for that : a success story...
    My (brain storm) Methodology should follow these steps:
     Resource bottlenecks: CPU, memory, and I/O bottlenecks
     tempdb bottlenecks
     A slow-running user query : Missing indexes, statistics,...
     Use performance counters : there are many, can one give us the list of the most important
    how to do fine tuning about SQL Server configuration
    SSRS, SSIS configuration ? 
    And do the recommandations.
    Thanks
    "there is no Royal Road to Mathematics, in other words, that I have only a very small head and must live with it..."
    Edsger W. Dijkstra

    Hello,
    There is no clear defined step which can be categorized as step by step to performance tuning.Your first goal is to find out cause or drill down to factor causing slowness of SQL server it can be poorly written query ,missing indexes,outdated stats.RAM crunch
    CPU crunch so on and so forth.
    I generally refer to below doc for SQL server tuning
    http://technet.microsoft.com/en-us/library/dd672789(v=sql.100).aspx
    For SSIS tuning i refer below doc.
    http://technet.microsoft.com/library/Cc966529#ECAA
    http://msdn.microsoft.com/en-us/library/ms137622(v=sql.105).aspx
    When I face issue i generally look at wait stats ,wait stats give you idea about on what resource query was waiting.
    --By Jonathan KehayiasSELECT TOP 10
    wait_type ,
    max_wait_time_ms wait_time_ms ,
    signal_wait_time_ms ,
    wait_time_ms - signal_wait_time_ms AS resource_wait_time_ms ,
    100.0 * wait_time_ms / SUM(wait_time_ms) OVER ( )
    AS percent_total_waits ,
    100.0 * signal_wait_time_ms / SUM(signal_wait_time_ms) OVER ( )
    AS percent_total_signal_waits ,
    100.0 * ( wait_time_ms - signal_wait_time_ms )
    / SUM(wait_time_ms) OVER ( ) AS percent_total_resource_waits
    FROM sys.dm_os_wait_stats
    WHERE wait_time_ms > 0 -- remove zero wait_time
    AND wait_type NOT IN -- filter out additional irrelevant waits
    ( 'SLEEP_TASK', 'BROKER_TASK_STOP', 'BROKER_TO_FLUSH',
    'SQLTRACE_BUFFER_FLUSH','CLR_AUTO_EVENT', 'CLR_MANUAL_EVENT',
    'LAZYWRITER_SLEEP', 'SLEEP_SYSTEMTASK', 'SLEEP_BPOOL_FLUSH',
    'BROKER_EVENTHANDLER', 'XE_DISPATCHER_WAIT', 'FT_IFTSHC_MUTEX',
    'CHECKPOINT_QUEUE', 'FT_IFTS_SCHEDULER_IDLE_WAIT',
    'BROKER_TRANSMITTER', 'FT_IFTSHC_MUTEX', 'KSOURCE_WAKEUP',
    'LAZYWRITER_SLEEP', 'LOGMGR_QUEUE', 'ONDEMAND_TASK_QUEUE',
    'REQUEST_FOR_DEADLOCK_SEARCH', 'XE_TIMER_EVENT', 'BAD_PAGE_PROCESS',
    'DBMIRROR_EVENTS_QUEUE', 'BROKER_RECEIVE_WAITFOR',
    'PREEMPTIVE_OS_GETPROCADDRESS', 'PREEMPTIVE_OS_AUTHENTICATIONOPS',
    'WAITFOR', 'DISPATCHER_QUEUE_SEMAPHORE', 'XE_DISPATCHER_JOIN',
    'RESOURCE_QUEUE' )
    ORDER BY wait_time_ms DESC
    use below link to analyze wait stats
    http://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/
    HTH
    PS: for reporting services you can post in SSRS forum
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

Maybe you are looking for

  • Controlling properties on items added to the stage in a loop

    Hi there, I have a loop that adds xml elements to the stage (10). Once added, I need to control the items (checkbox = do something). Here is where I add them to the stage.           private function createLayout():void {                container = ne

  • JTree and background image

    How do I put background image into jTree?

  • My Website name

    I know I know there are a ton of questions like this, but I think mine is hopefully simple one. My website name is suppose to be www.palmyrapanthers.net when my publishing was done (by the way I am new to this how long does publishing take?) I was ab

  • MySQL/XE with Excel

    I have a macro-enabled excel sheet that I use to track activities. cells within this excel sheet use colors to represent value instead of numbers. As many users are accessing this file on file share I started to think to link it to a table in databas

  • Can't buy in app purchase, Can't buy in app purchase

    Tern on app purchase at my ipad then click buy button. After then i put my credit card details but can't buy game. and I still didn't received duplication invoice money all.