Performance Tuning and Control StatementsPerformance Tuning and Control StatementsPerperformance Tuning and Control Statements

Embed Size (px)

Citation preview

  • 8/11/2019 Performance Tuning and Control StatementsPerformance Tuning and Control StatementsPerperformance Tuning and Control Statements

    1/12

    Performance tuning and control statements.

    Run-time analysis+-

    Run-time analysis is used to check the eciency of a program or function module

    or t-code in terms of what is the load on the database server, application server,presentation server etc.

    The run-time analysis will display the load in a graph with !s and the time inmicro seconds.

    The graph will be displayed with either red color or green color.

    "f the graph contains green color, then the program e#ecution time is very goodor very less.

    "f the graph contains red color, the program e#ecution time is very bad or verylong .

    $lways make sure the the load on database server should be less than %& andshould be green.

    T-code for run-time analysis is '()& or '$T*atest ersions.

    (#ample program on run time analysys in '$P $$PProgram/0 1reate a program to get 2$R$ details and display as below.

    R(P3RT 4'$56'()&.

    77Runtime analysis using '()&

    8$T$ 0 "T62$R$ T9P( T$( 3: 2$R$.

    8$T$ 0 ;$62$R$ T9P( 2$R$.

    '((1T 7 :R32 2$R$ "5T3 T$( "T62$R$

  • 8/11/2019 Performance Tuning and Control StatementsPerformance Tuning and Control StatementsPerperformance Tuning and Control Statements

    2/12

    The result will be like below*may vary based on server capacity.

    "n the above image you can see $$P and database layers are in red color, means thetime taken to process these layers is more.Program0B

    5ow change the above program like below and test again.

  • 8/11/2019 Performance Tuning and Control StatementsPerformance Tuning and Control StatementsPerperformance Tuning and Control Statements

    3/12

    R(P3RT 4'$56'()&.

    T9P('0 (A"5 3: T962$R$,

    2$T5R T9P( 2$R$-2$T5R,

    2T$RT T9P( 2$R$-2T$RT,

    2R'? T9P( 2$R$-2R'?,

    2$T@ T9P( 2$R$-2$T@,

    2("5' T9P( 2$R$-2("5',

    (58 3: T962$R$.

    77Runtime analysis using '()&

    8$T$ 0 "T62$R$ T9P( T$( 3: T962$R$.

    8$T$ 0 ;$62$R$ T9P( ty62$R$.

    '((1T 2$T5R 2T$RT 2R'? 2$T@ 2("5' :R32 2$R$ "5T3 T$( "T62$R$

  • 8/11/2019 Performance Tuning and Control StatementsPerformance Tuning and Control StatementsPerperformance Tuning and Control Statements

    4/12

    5ow the evaluation will be like below.

    9ou can see the database layer is in green color means the standards are good.$ good program with coding standards always have database layers is in green color

    'T&= is a T-code which is used to trace performance of '$P 3bCects, things we can doneusing 'T&= are below.

  • 8/11/2019 Performance Tuning and Control StatementsPerformance Tuning and Control StatementsPerperformance Tuning and Control Statements

    5/12

    'D Trace which is used to trace time e#ecution for open 'D statements likeselect, insert, update, delete etc.

    (nEueue Trace which is used to trace locking and unlocking of lock obCects.

    uFer Trace, this is used to monitor table buFer accesses.

    R:1 Trace, this is used to trace remote calls made of a application.

    ?TTP Trace which is used to trace ?TTP reEuests*e#0 browser reEuests of '$Papplications.

    To perform trace operations go to 'T&=, select trace, activate trace, open anothersession and e#ecute the application which we wants to trace, comeback to 'T&=,deactivate the trace and display the trace.

    +-

  • 8/11/2019 Performance Tuning and Control StatementsPerformance Tuning and Control StatementsPerperformance Tuning and Control Statements

    6/12

    Programming Standard Bad example Good example

    5ever use select 7, alwaysuse select with list ofGelds because if you useselect 7 it will get allcolumns from database, ifyou use select list of Geldsit will get selectedcolumns only.

    '((1T 7 :R32 2$R$

    "5T3 T$( ...'((1T 2$T5R 2T$RT 2("5'2R'? :R32 2$R$ ..

    $lways specify key Geldsin where condition,because it will be havingprimary inde#.

    '((1T 7 :R32 2$R$

    "5T3 T$( "T62$R$

    ;?(R( 2T$RT H !:(RT!.

    '((1T 2$T5R 2T$RT 2("5':R32 2$R$

    "5T3 T$( "T62$R$

    ;?(R( 2$T5R H !&&&/!.

    'ome times we may needto use non-key Gelds inwhere condition, in suchcases create secondaryinde# to improveperformance.

    5ever use select withcorresponding .

    '((1T 7 :R32 2$R$

    "5T3 13RR('P358"5A :"(8'3: T$( "T62$R$.

    '((1T 2$T5R 2T$RT 2("5':R32 2$R$

    "5T3 T$( "T62$R$.

    $lways use read table keywith binary search, binarysearch will improveperformance.

    R($8 T$( "T62$R$ "5T3;$62$R$ ;"T? @(9 2$T5R H!&&/!

    "5$R9 '($R1?.

    R($8 T$( "T62$R$ "5T3;$62$R$ ;"T? @(9 2$T5R H!&&/!.

    $void using select Coinsfor more than ) databasetables.

    'elect Ioins in '$P $$P

  • 8/11/2019 Performance Tuning and Control StatementsPerformance Tuning and Control StatementsPerperformance Tuning and Control Statements

    7/12

    Programming Standard Bad example Good example

    5ever use nested loops.

    33P $T "T62$R$ "5T3;$62$R$.

    33P $T "T62$@T "5T3;$62$@T.

    (5833P.JbrK(5833P.JbrK

    33P $T "T62$R$ "5T3

    ;$62$R$.JbrKR($8 T$("T62$@T "5T3 ;$62$@T ;?(R(2$T5R H ;$62$R$-2$T5R.JbrKJbrK(5833P.

    5ever use selectstatements inside loops .

    JbrK33P $T "T62$R$ "5T3;$62$R$.JbrK'((1T 7 :R322$@T ...JbrKJbrK(5833P.

    "5'T($8

  • 8/11/2019 Performance Tuning and Control StatementsPerformance Tuning and Control StatementsPerperformance Tuning and Control Statements

    8/12

    ;$62@( T9P( T962@(.

    '((1T

    2$T5R

    2T$RT

    2R'?

    2$T@

    2("5' :R32 2$R$ "5T3 T$( "T62$R$

    ;$62$R$-2$T5R, ;$62$R$-2T$RT, ;$62$R$-2$T@, ;$62@(-@3RA,;$62@(-T;(A.

    (5833P.

    (5833P.

    Program with parallel cursor.R(P3RT 4'$56P$R$(61

  • 8/11/2019 Performance Tuning and Control StatementsPerformance Tuning and Control StatementsPerperformance Tuning and Control Statements

    9/12

  • 8/11/2019 Performance Tuning and Control StatementsPerformance Tuning and Control StatementsPerperformance Tuning and Control Statements

    10/12

    /. ;hen reading data from database table, never use '((1T 7,always use select with list of Gelds.

    B. $lways specify key Gelds in where conditions of '((1Tstatements, because these will have primary inde#.

    ). 'ometimes we may need to use non-key Gelds in whereconditions of '((1T statements, in that case createsecondary inde#es and use.

    %. 5ever use select with corresponding in '((1T statements.

    =. $lways use read table with binary search and make you havesorted the internal table in ascending order before using readtable binary search.

    N. 5ever use select Coins for more than ) tables.

    O. $lways use select for all entries for more than ) tables.

    . $lways check whether the parent internal table is initial or notbefore using for all entries.

    Q. 5ever use nested loops, instead use parallel cursor .

    /&. 5ever use select statements inside loops, instead use forall entries.

    $lso read performance truing in '$P $$P programming , binary search mechanism in'$P $$P

    1ontrol break statements are statements which are used to control the seEuence ofe#ecution of statements with in loop.....endloop.

    These statements are e#ecuted only with in loop...endloop.

    1ontrol break statements are$T :"R'T - This statement is e#ecuted>triggered for the Grst iteration of loop *'9-T$"L H/ .

    $T $'T- This statement is e#ecuted>triggered for the last iteration of loop.

    $T 5(; JGeld nameK- This is e#ecuted when ever there is a new value on speciGed Geld.

    $T (58 3: JGeld nameK- This statement is e#ecuted whenever the new value ends onspeciGc Geld.

    35 1?$5A( 3: JGeld nameK- "t is same as $T 5(; and is obsolete in (11 N.&.

    https://www.sapnuts.com/courses/core-abap/performce-tuning/parallel-cursor-sapabap.htmlhttps://www.sapnuts.com/courses/core-abap/performce-tuning.htmlhttps://www.sapnuts.com/tutorials/Binary-Search-mechanism-in-SAP.htmlhttps://www.sapnuts.com/tutorials/Binary-Search-mechanism-in-SAP.htmlhttps://www.sapnuts.com/courses/core-abap/performce-tuning/parallel-cursor-sapabap.htmlhttps://www.sapnuts.com/courses/core-abap/performce-tuning.htmlhttps://www.sapnuts.com/tutorials/Binary-Search-mechanism-in-SAP.htmlhttps://www.sapnuts.com/tutorials/Binary-Search-mechanism-in-SAP.html
  • 8/11/2019 Performance Tuning and Control StatementsPerformance Tuning and Control StatementsPerperformance Tuning and Control Statements

    11/12

    Requirement:8evelop a report to display list of sales orders with totals and page sub-totals for a particular date.'election-screen 0 input date.

    SUM0 'B !'$(' 831!, / !2$TR"$!, B!D

  • 8/11/2019 Performance Tuning and Control StatementsPerformance Tuning and Control StatementsPerperformance Tuning and Control Statements

    12/12

    ;R"T( 0>B) !'B) !Total is0!, ;$6$P-5(TPR .

    (58$T.

    (5833P.