如何提高FOR ALL ENTRIES的查询性能主要从两个方面入手
1 对FOR ALL ENTRIES的驱动表按比较关键字排序;
2 删除FOR ALL ENTRIES的驱动表中比较关键字排序;
REPORT ZEXIT_HELP no standard page heading.
DATA: it_mara TYPE STANDARD TABLE OF mara,
wa_mara TYPE mara,
it_makt TYPE STANDARD TABLE OF makt,
wa_makt TYPE makt,
it_temp_mara TYPE STANDARD TABLE OF mara,
wa_temp_mara TYPE mara.
* Get all the records from MARA
SELECT * FROM mara
INTO TABLE it_temp_mara.
IF sy-subrc = 0.
IF it_temp_mara[] IS NOT INITIAL.
* Duplicate the driver table with the data
do 2 times.
append lines of it_Temp_mara to it_mara.
enddo.
IF it_mara[] IS NOT INITIAL.
* Select MAKT
perform select_makt.
*After Sorting
sort it_mara by matnr.
perform select_makt.
* After deleting duoplicateentries
DELETE ADJACENT DUPLICATES FROM it_mara COMPARING matnr.
perform select_makt.
ENDIF.
ENDIF.
ENDIF.
*&---------------------------------------------------------------------*
*& Form select_makt
*&---------------------------------------------------------------------*
* Select data friom MAKT
*----------------------------------------------------------------------*
form select_makt .
DATA: t1 TYPE i,
t2 TYPE i,
tmin TYPE i.
refresh it_makt[].
GET RUN TIME FIELD t1.
SELECT *
FROM makt
INTO TABLE it_makt
FOR ALL ENTRIES IN it_mara
WHERE matnr = it_mara-matnr.
GET RUN TIME FIELD t2.
tmin = t2 - t1.
tmin = tmin .
WRITE:/ ' Time(ms) = ', tmin.
Endform. "select_makt
测试结果
No of run |
Records in MARA |
Records in MAKT |
Time required ( mili-seconds) |
Before sort |
After Sort |
After sort and delete adjacent duplicates |
1 |
12053 |
71907 |
4040.26 |
3373.738 |
2017.051 |
2 |
12053 |
71907 |
4784.953 |
3387.241 |
2007.644 |
Average Time |
|
|
|
几个注意点:
1、有FOR ALL ENTRIES IN itab的不能使用order by;
2、如果 itab无数据,where语句就当没有条件处理;
3、系统自动删除重复纪录;
关于ranges和FOR ALL ENTRIES IN的使用大家可以参阅SAP的标准代码的使用方法,代码参见函数MRM_INVHEAD_MANY_READ,摘抄如下:
SORT t_lifnr.
DELETE ADJACENT DUPLICATES FROM t_lifnr.
DESCRIBE TABLE t_lifnr LINES count.
if count < 5000.
SELECT * FROM rbkp INTO TABLE t_rbkp
WHERE belnr IN t_belnr
AND gjahr IN t_gjahr
AND bukrs IN t_bukrs
AND bldat IN t_bldat
AND budat IN t_budat
AND lifnr IN t_lifnr
AND ivtyp IN rg_ivtyp.
else.
SELECT * FROM rbkp INTO TABLE t_rbkp
FOR ALL ENTRIES IN t_lifnr
WHERE lifnr = t_lifnr-low
AND belnr IN t_belnr
AND gjahr IN t_gjahr
AND bukrs IN t_bukrs
AND bldat IN t_bldat
AND budat IN t_budat
AND ivtyp IN rg_ivtyp.
endif.
分享到:
相关推荐
文档的描述部分提供了更为具体的信息:“IEEE Guide for Improving the Lightning Performance of Electric Power Overhead Distribution Lines”(IEEE关于提升电力架空配电线路雷电性能的指南)。这表明文档是由...
Optimizing Java_Practical Techniques for Improving JVM Application Performance-O’Reilly(2018) How do you define performance? Most developers, when asked about the performance of their application, ...
The investigation produced detailed measurements in order to profile the application and help on improving the performance. Code analysis shows that the current IPOP version suffers from ...
Understand the pitfalls of measuring Java performance numbers and the drawbacks of microbenchmarking Dive into JVM garbage collection logging, monitoring, tuning, and tools Explore JIT compilation and...
In this paper, we focus on the problem of context-aware recommendation using tensor factorization. Tra- ditional tensor-based models in context-aware recommendation scenario only consider user-item-...
### 提升Linux下千兆以太网驱动性能 #### 概览 本文档主要讨论了在Linux环境下如何提升千兆以太网驱动的性能。它不仅涵盖了基础的驱动原理介绍,还包括了一些具体的优化方法,例如发送中断节制、TCP慢启动改进以及...
论文《Autoencoders for improving quality of process event logs》翻译
This eagerly awaited new edition has been fully updated to reflect crucial changes in the programming landscape.Refactoring, Second Edition,features an updated catalog of refactorings and includes ...
Refactoring Improving The Design Of Existing Code
Improving TCP Performance over Wireless Networksat the Link Lay 英文原版 We present the transport unaware link improvement protocol (TULIP), which dramatically improves the performance of TCP over ...
在本文档"Improving Execution Performance on SPI Flash of NUC505"中,主要讨论了如何通过将关键代码和数据移动到SRAM中以提高基于32位NuMicro®系列微控制器(特别是NUC505系列)在SPI闪存上的执行性能。...
提高静电纺丝制备一系列LiNi1/3-xCo1/3Mn1/3+xO2样品的电化学性能的方法,张芸,顾大伟,本文采用静电纺丝的方法成功合成了一系列镍钴锰酸锂正极材料 LiNi1/3-xCo1/3Mn1/3+xO2(x=0,1/18,1/15,1/12)。...
《重构:改善既有代码的设计》是一本专注于软件开发领域的经典著作,由Martin Fowler著述,主要探讨了如何通过重构技术来提升现有代码的设计质量。重构是软件开发过程中的一个重要环节,它并不改变软件的外部行为,...
platforms are driving the need not only for greater networking bandwidth, but also for more efficient processing of network data. The lower power usage and greater processing capabilities of these ...
- **Refactoring Tools for Visual Studio**:针对.NET平台的重构插件。 **5. 面向对象设计的优化** 重构不仅仅局限于简单的代码优化,它还涉及到更深层次的面向对象设计原则。通过遵循良好的设计原则,如单一...
《重构:改善既有代码的设计》是由马丁·福勒(Martin Fowler)、厄文·贝克(Erich Beck)、戴夫·布兰特(Dave Brant)和安德鲁·奥普迪克(Andreas Opdyke)以及约翰·罗伯茨(John Roberts)合著的一本经典软件...
Refactoring Improving The Design of Existing Code 重构已有代码