Download presentation
Presentation is loading. Please wait.
Published byJacob Noah Mason Modified over 8 years ago
1
ABAP Performance Tuning for SAP R/3 1 ABAP Performance Tuning
2
ABAP Performance Tuning for SAP R/3 2 튜닝의 요소 Application Tuning 70 % (SQL, 인덱스, 뷰,JOIN,Array, 부분 처리 ) System Tuning 20 % (OS,I/O, 메모리,DBMS..) 기타 10%
3
ABAP Performance Tuning for SAP R/3 3 Array Mode and Workarea Mode StatementABAP <- DBIFDBIF <- DBMS INSERT, UPDATE, DELETE wawa SELECT... ENDSELECTwaarray SELECT... INTO TABLEarray INSERT, UPDATE, DELETE FROM TABLEarrayarray / wa MODIFY FROM TABLEarraywa StatementABAP -> DBIFDBIF -> DBMS SELECT... FOR ALL ENTRIESarray UPDATE... SET... WHEREstatement
4
ABAP Performance Tuning for SAP R/3 4 Database architecture
5
ABAP Performance Tuning for SAP R/3 5 Rules of Efficient Database Programming (I) 1. Keep the hit set small –specify everything you know in the WHERE clause 2. Keep data to be transferred small –projection views and field lists –no workarea update –aggregate functions and group by 3. Keep the number of transfers small –use array changes –avoid nested selects (possible alternatives: joins, subselects, explicit cursors) 4. Keep the area to be searched small –let the database use the indexes in an optimal way –create good indexes
6
ABAP Performance Tuning for SAP R/3 6 Rules of Efficient Database Programming (II) 5. Take load off the database where possible –Table buffering –Avoid repeated reading of data (e.g. use global reading module for master data) –Avoid SELECT before changes –Avoid restart logic for mass data processing Better use open cursor with hold –Use SORT instead of ORDER BY where possible –Use DELETE ADJACENT instead of DISTINCT where possible –Use logical databases only if design is appropriate –Avoid dynamic SQL because it is not using buffering mechanisms
7
ABAP Performance Tuning for SAP R/3 7 ABAP/4 Performance Tuning(Technique # 1) Bad statement SELECT * FROM table Ex) SELECT * FROM VBAK ….. WRITE : / VBAK-VBELN, …….. ENDSELECT. Good statement SELECT col1,col2 into(col1,col2) FROM table Ex) SELECT VBELN, AUART, BNAME, KUNNR INTO (VBAK-VBELN, VBAK-AUART,.) FROM VBAK ….. WRITE : / VBAK-VBELN, VBAK-AUART,. 결론 : 1000 레코드 선택시 SELECT * FROM table 2,910,000 ms(micro seconds) SELECT col1,col2.. 239,000 ms DB SVR 와 AP SVR 간 데이터 전송 부하가 적고, 데이터 베이스의 I/O 횟수를 줄임. 필요한 컬럼을 선택하여 AP SVR 의 버퍼에 loading 함으로 전체 메모리 사용률을 줄일 수 있음
8
ABAP Performance Tuning for SAP R/3 8 ABAP/4 Performance Tuning(Technique # 2) Bad statement SELECT FROM table... EXIT Ex) SELECT VBELN BNAME INTO (VBAK-VBELN,.) FROM VBAK. IF SY-DBCNT > 1000. EXIT. ENDIF. WRITE : / VBAK-VBELN, VBAK-BNAME,……. ENDSELECT. Good statement SELECT col1,col2 into(col1,col2) FROM table UPTO n ROWS Ex) SELECT VBELN, AUART, BNAME, KUNNR INTO (VBAK-VBELN, VBAK- AUART,.) FROM VBAK ….. UPTO 1 ROWS. WRITE : / VBAK-VBELN, VBAK-AUART,. 결론 : 1000 레코드 선택시 SELECT... EXIT. ENDSELECT. 410,000 ms SELECT.. UPTO 1 ROWS 368,000 ms
9
ABAP Performance Tuning for SAP R/3 9 ABAP/4 Performance Tuning(Technique # 3) Bad statement SELECT FROM table... CHECK Ex) SELECT VBELN … INTO ( VBAK-VBELN, ….) FROM VBAK. CHECK VBAK-VBELN+7(1) = ‘9’. WRITE : / VBAK-VBELN,…… ENDSELECT. Good statement SELECT col1,col2 into(col1,col2) FROM table WHERE Clause Ex) SELECT VBELN, AUART, BNAME, KUNNR INTO (VBAK-VBELN, VBAK-AUART,.) FROM VBAK … WHERE VBAK-VBELN LIKE ‘-------9---‘. WRITE : / VBAK-VBELN, VBAK-AUART,. 결론 : 57,000 레코드 선택시 SELECT... CHECK. 27,958,000 ms SELECT …WHERE clause. 3,065,000 ms
10
ABAP Performance Tuning for SAP R/3 10 ABAP/4 Performance Tuning(Technique # 4) Bad statement DBMS sort 사용 Ex) SELECT VBELN.. INTO (VBAK-VBELN,…..) FROM VBAK WHERE BNAME IN S_BNAME ORDER BY BNAME Good statement AP 서버 internal table sort 사용 Ex) SELECT VBELN, AUART, BNAME, KUNNR INTO TABLE IVBAK FROM VBAK WHERE BNAME IN S_BNAME. SORT IVBAK BY BNAME.
11
ABAP Performance Tuning for SAP R/3 11 ABAP/4 Performance Tuning(Technique # 5) Bad statement SELECT & APPEND Ex) SELECT VBELN …. INTO (IVBAK-VBELN,… ) FROM VBAK WHERE BNAME IN S_BNAME APPEND IVBAK ENDSELECT. Good statement SELECT INTO TABLE Ex) SELECT VBELN, AUART, BNAME, KUNNR INTO TABLE IVBAK FROM VBAK WHERE BNAME IN S_BNAME.
12
ABAP Performance Tuning for SAP R/3 12 ABAP/4 Performance Tuning(Technique # 6) Bad statement NESTED SELECTS Ex) SELECT VBELN AUART VTWEG VKORG SPART INTO IVBAK FROM VBAK WHERE VBELN BETWEEN..... AND...... SELECT POSNR MATNR ZMENG MEINS INTO IVBAP FROM VBAP WHERE VBELN = IVBAK-VBELN. WRITE : /IVBAK-VBELN,....... ENDSELECT. Good statement 데이터 베이스 VIEWS 사용 Ex) SELECT * FROM ZV_VBAK WHERE VBELN BETWEEN.... AND.... WRITE : ZV_VBAK-VBELN,..... ENDSELECT. 데이터 베이스 view 는 tables join, columns projection, rows selection 에 의한 logical table 임. Join 문장을 사용 할 수 있음 SAP R3 3.1 부터 ABAP SQL 에서 JOIN 가능함.
13
ABAP Performance Tuning for SAP R/3 13 ABAP/4 Performance Tuning(Technique # 7) Bad statement ABAP CALCULATIONS(Collect) Ex) SELECT MATNR KWMENG MEINS INTO VBQTY FROM VBAPWHERE ….. COLLECT VBQTY. ENDSELECT. Good statement DBMS SUM, AVG, MIN, MAX 기능 사용 Ex) SELECT MATNR SUM(KWMENG) MEINS INTO TABLE VBQTY FROM VBAP WHERE ….. GROUPBY ….. 합계, 평균, 최대값, 최소값 등 수를 계산할 때 DBMS 의 기능을 사용하는 것이 좋다. 최적의 logic 으 로 처리 하기 때문임.
14
ABAP Performance Tuning for SAP R/3 14 ABAP/4 Performance Tuning(Technique # 8) Bad statement READ TABLE..WITH KEY. Ex) SELECT VBELN KUNNR.... INTO TABLE IVBAK WHERE.......... READ TABLE IVBAK WITH KEY VBELN = ‘00900000090’. Good statement READ TABLE..WITH KEY. BINARY SEARCH ( TRANSPORTING NO FIELDS) Ex) SELECT VBELN KUNNR.... INTO TABLE IVBAK WHERE.......… READ TABLE IVBAK WITH KEY VBELN = ‘ 00900000090’. BINARY SEARCH ( TRANSPORTING NO FIELDS) Large internal table 을 처리할 때 binary search transport no fields 를 사용 한다.
15
ABAP Performance Tuning for SAP R/3 15 ABAP/4 Performance Tuning(Technique # 9) Bad statement LOOP AT ITAB1. MOVE ITAB1 TO ITAB2. APPEND ITAB2. ENDLOOP. Good statement Itab2[ ] = itab1[ ]. 같은 구조 internal table 간 데이터 이동을 전제로 함.
16
ABAP Performance Tuning for SAP R/3 16 ABAP/4 Performance Tuning(Technique # 10) Bad statement LOOP AT ITAB1. MOVE ITAB1 TO ITAB2. APPEND ITAB2. ENDLOOP. Good statement APPEND LINES OF ITAB1 TO ITAB2. Internal table 내 data append 하기
17
ABAP Performance Tuning for SAP R/3 17 ABAP/4 Performance Tuning(Technique # 11) Bad statement LOOP AT IVBAK WHERE BNAME = ‘SMITH’. DELETE BNAME. ENDLOOP. Good statement DELETE IVBAK WHERE BNAME = ‘SMITH’. Internal table 내 data 삭제하기.
18
ABAP Performance Tuning for SAP R/3 18 ABAP/4 Performance Tuning(Technique # 12) Bad statement select * from vbap where vblen = vbak-vblen. check vbap-pstyv = ‘ZRE3’. check vbap-werks = ‘0100’. Good statement select * from vbap where vblen = vbak- vblen and pstyv= ‘ZRE3’ and werks=‘0100’. Transparent table 를 select 할 경우 가능한 모든 key field 를 where 절에 사용 하라. Bad statement 는 Application server 의 많은 memory 가 이용 된다.
19
ABAP Performance Tuning for SAP R/3 19 ABAP/4 Performance Tuning(Technique # 13) Bad statement select * from bseg where bukrs= bsik-bukrs and rebzg=bsik-belnr and lifnr=bsik-lifnr and shkzg=‘S’ and koart=‘K’. Good statement select * from bseg where bukrs=bsik-bukrs and rebzg=bsik-belnr. check lifnr=bsik-lifnr. check shkzg=‘S’. check koart=‘K’. Pool,cluster table 의 data 는 위의 statement 가 parse 되기 전 data 부분을 unpack 시켜야 만 한다. 따라서 해당 logical table 의 key field 만 where 절에 사용하고, 나머지는 check 문장에 사용한다.
20
ABAP Performance Tuning for SAP R/3 20 ABAP Performance Tuning( 기 타 ) Native SQL 활용 오라클 DB link 사용시 SQL join 문장 사용시 SELECT SINGLE 을 자주 사용 key 를 잘 만들자 (index) Index full scan 보다는 table full scan 이 오히려 좋다. R3 특성상 mandt field 로 인해 index full scan 을 초래함. Index 는 single block read 이고,table 은 multi block read 임. Select ~ option 중 client specified 에 의해 mandt field 를 ABAP 문장에서 사용 가능함. Read only table 은 buffering 을 활용하라. Full buffering( 작은 table),Generic buffering( 큰 table) 을 사용할 수 있다. SQL Trace 와 ABAP trace 를 적절히 사용하라. Index 사용여부,full scan,DB 및 AP 서버 사용 비율 등을 점검하여 튜닝 POINT 확인
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.