ABAP「FOR ALL ENTRIES」的Hints 優化
通常預設情況下「FOR ALL ENTRIES IN」語句會將內表每5個資料生成一個新的Where語句來執行。
可通過事務程式碼「RZ11」查詢引數名稱「rsdb/max_blocking_factor」,如下圖所示。
比如下面的程式碼(僅供測試):
REPORT ZTEST. DATA : BEGIN OF LT_KNA1 OCCURS 0, KUNNR TYPE KNA1-KUNNR, END OF LT_KNA1. DATA : LT_KNB1 LIKE TABLE OF KNB1 WITH HEADER LINE. START-OF-SELECTION. SELECT * FROM KNA1 INTO CORRESPONDING FIELDS OF TABLE LT_KNA1. IF LT_KNA1[] IS NOT INITIAL. SELECT * FROM KNB1 INTO TABLE LT_KNB1 FOR ALL ENTRIES IN LT_KNA1 WHERE KUNNR = LT_KNA1-KUNNR. ENDIF. WRITE : 'Finish!'.
|
我們用事務程式碼「ST05」跟蹤執行後可以發現,預設確實是讀取內表中的五條資料。
為了減少與資料庫的互動,縮減Select語句的次數,我們可以在Select語句的最後加上了這樣一句話,每次讀取的資料就會發生變化。
%_HINTS ORACLE '&max_blocking_factor 20& &max_in_blocking_factor 20&'
(這裡注意若是HANA資料庫,需要換成%_HINTS HDB)
但是,rsdb/max_blocking_factor 設定的過大可能會使 SQL 超長,造成程式 DUMP,所以設定需謹慎。
【擴充套件學習】
- rsdb/MB_CUR_MAX
- rsdb/_create_single_client_cond
- rsdb/cua/buffersize
- rsdb/cua/max_objects
- rsdb/cua/mutex_n
- rsdb/db2jcl_library
- rsdb/dbhost
- rsdb/dbid
- rsdb/esm/buffersize_kb
- rsdb/esm/large_object_size
- rsdb/esm/max_objects
- rsdb/esm/mutex_n
- rsdb/fda_level
- rsdb/fda_shm_seg_size
- rsdb/icli_library
- rsdb/max_blocking_factor
- rsdb/max_in_blocking_factor
- rsdb/max_union_blocking_factor
- rsdb/min_blocking_factor
- rsdb/min_in_blocking_factor
- rsdb/min_union_blocking_factor
- rsdb/ntab/entrycount
- rsdb/ntab/ftabsize
- rsdb/ntab/irbdsize
- rsdb/ntab/sntabsize
- rsdb/obj/buffersize
- rsdb/obj/large_object_size
- rsdb/obj/max_objects
- rsdb/obj/mutex_n
- rsdb/oracle_host_standby
- rsdb/oracle_sid_standby
- rsdb/otr/buffersize_kb
- rsdb/otr/max_objects
- rsdb/otr/mutex_n
- rsdb/prefer_fix_blocking
- rsdb/prefer_in_itab_opt
- rsdb/prefer_join
- rsdb/prefer_join_with_fda
- rsdb/prefer_union_all
- rsdb/rclu/opt_level
- rsdb/rda
- rsdb/reco_add_error_codes
- rsdb/reco_ping_cmd
- rsdb/reco_sleep_time
- rsdb/reco_sosw_for_db
- rsdb/reco_sync_all_server
- rsdb/reco_tcp_service
- rsdb/reco_trials
- rsdb/rep/fast_touch
- rsdb/ssfs_connect
- rsdb/staton
- rsdb/stattime
- rsdb/supports_fda_prot
- rsdb/tbi_buffer_area_MB
- rsdb/tbi_dir_entries
- rsdb/trace_modules
- rsdb/vmcj/codepage_compatibility