版权声明:本文为博主汪子熙原创文章,未经博主允许不得转载。 https://cloud.tencent.com/developer/article/1439491
It is an expensive operation to open a file in application server with 50MB file size.
Current logic is:
The correct logic should be:
Loop at all service BOM, check whether the ID in current loop does exist in validation table lt_valid_prod or lt_valid_sp. If so, delete them via DELETE TABLE XXX FROM .
Improvement: use DELETE XXX WHERE product_id NOT IN . It is more efficient when lt_srv_bom_file has a huge number of records. See comparison below ( unit: second )
这是一个性能问题。使用ABAP原生支持的NOT IN关键字可以获得更好的性能。性能评测如下:
In product / IObject area, the best practice is to use OPEN CURSOR / FETCH NEXT CURSOR to access big DB table.
如果需要用ABAP OPEN SQL读取一张包含海量记录的数据库表,那么推荐使用OPEN CURSOR进行分块读取。
Although this solution will spend almost the same time to fetch the data from DB, it has far less memory consumption compared with using SELECT to fetch ALL data from DB at one time.
The original dump due to out of memory issue could be eliminated by replace SELECT with OPEN CURSOR statement.
这种方式和直接用SELECT相比,能显著减少内存消耗量。
通过下面这段代码模拟一个费时的ABAP程序:
定义一个ABAP函数:
这个函数里执行一大堆计算,然后把传入的product ID写到一张自定义表ZJERRY1里。
调用这个函数的代码:
注意第二种方案使用STARTING NEW TASK达到的并发执行效果:
通过比较,第二种解决方案的效率是第一种的四倍。
parallel processing (Asynchronous RFC call).
processing.