当前位置:网站首页>ABAP随笔-程序优化笔记
ABAP随笔-程序优化笔记
2022-06-23 15:54:00 【Tab Zhu】
昨天做了一个别人的程序优化,朋友圈小伙伴留言,写出来看看是如何优化的。
取数逻辑上基本都改了。做这个程序优化真是痛并快乐着,首先拿到一个程序,不完全不知道逻辑,那么首先得看懂它的逻辑,然后想办法去优化。趁着这次机会,写一下ABAP的优化吧。
总的来说,对于S4 HANA 数据库执行要优于应用层的执行,但是我们需要减少数据库和应用层的交互次数。
1.尽量明确自己要取得字段,
优化之前 | 优化之后 |
|---|---|
SELECT * FROM LIPS INTO TABLE @ITABWHERE ··· | SELECT VBELN,POSNR,MATNR INTO TABLE @ITAB WHERE ··· |
2.在select 查询时,特别是需要经过选择界面筛选处理的,尽量使用inner join ( left outer join) 一次性抓取出来。别使用for all entries in。
如:选择屏幕上有
3.在写for all entries in 的时候注意点
1.写全你要所要取数据的主键,来保证每条数据是唯一的,因为forall entries in 自带selectdistinct去重功能.(直接把所要取得表得主键都写上呗)
2.先判断下for allentries in itab 这个表是否为空,ifitab[] is not initial 一定要有,这个ABAPer应该都知道
3.使用时可以将itab 按照for all entries in的条件排序去重一下,来尽可能缩小itab表,如下:
4.for all entries in 非常消耗内存,当itab过大的时候不建议使用,若是你一定要用请这么操作:(当itab过大时,会引起资源瓶颈)
4.内表的使用方面
a) 尽量使用hash表,其次是sort表,然后再是standard表
注:尽量使用sort表吧,实际实施过程中,哈希表用的还是很少的,很多时候我们需要很灵活的对表进行各种字段排序,Sort表的插入数据会比标准表要耗时。
b) 使用 LOOP AT GT_OUT ASSIGNING FIELD-SYMBOL(<FS>).会比使用 into要好,特别是需要修改数据的时候。当然用loop at itab , at end of , sum求和不能使用<fs>了。
使用<fs>时,遇到at end of 操作,<fs>中数据不会变成*
c) 常用: read table 时 注意排序,然后使用binary search来提高效率
它的升级版就是提升双层loop的效率,这个在合计值和子表不止一个值和主表对应时比较好用。
d) 对内表进行删除操作时,最好这么操作
e) 合计值的时候使用collect
这个语句还是挺高效的。
合计6W多条数据:
同时新语法:LOOP AT GROUP 在合计方面也是挺好使用得
同样的数据,相对比collet还是要逊色一点
但是下面这个图就让我体会了一把HANA数据库的强大
代码是:
5.使用SE30和 ST05取分析程序各个部分的执行时间
进入SE30:选择OLD SE30,点击左下角的分析,你可以看到程序的ABAP时间和DB时间
现在一般使用新得SE30,可以看到每个部分执行得时间,进而进行优化
END
边栏推荐
- 2022 Jiufeng primary school (Optics Valley No. 21 primary school) student source survey
- Thread pool
- 解读2022年度敏捷教练行业现状报告
- CoAtNet: Marrying Convolution and Attention for All Data Sizes翻译
- Sleuth + Zipkin
- Uniapp sends picture messages to Tencent instant messaging Tim
- How to select securities companies? Is it safe to open a mobile account?
- [tcapulusdb knowledge base] tcapulusdb tmonitor module architecture introduction
- ASEMI快恢复二极管RS1M、US1M和US1G能相互代换吗
- 《ThreadLocal》
猜你喜欢
NLP 论文领读|改善意图识别的语义表示:有监督预训练中的各向同性正则化方法

安全舒适,全新一代奇骏用心诠释老父亲的爱

如何让销售管理更高效?

Implementation of golang bubble sort code

A tour of grpc:01 - Basic Theory

2022 Jiufeng primary school (Optics Valley No. 21 primary school) student source survey

Block, non block, multiplexing, synchronous, asynchronous, bio, NiO, AIO

出现Identify and stop the process that‘s listening on port 8080 or configure this application等解决方法
![[tcapulusdb knowledge base] Introduction to tmonitor system upgrade](/img/7b/8c4f1549054ee8c0184495d9e8e378.png)
[tcapulusdb knowledge base] Introduction to tmonitor system upgrade
![[tcapulusdb knowledge base] Introduction to tmonitor background one click installation (I)](/img/d7/3a514fb75b3df487914a8db245ab89.png)
[tcapulusdb knowledge base] Introduction to tmonitor background one click installation (I)
随机推荐
How did Tencent's technology bulls complete the overall cloud launch?
Image saving: torchvision utils. save_ image(img, imgPath)
元宇宙带来的社会结构和资本制度演变
ADB 按鍵名、按鍵代碼數字、按鍵說明對照錶
Opengauss database source code analysis series articles -- detailed explanation of dense equivalent query technology (Part 2)
Leetcode: question d'entrevue 08.13. Empiler la boîte [DFS en haut + mémoire ou tri en bas + DP]
短视频平台开发,点击输入框时自动弹出软键盘
How does the web container initialize third-party plug-ins
JSON in MySQL_ Extract function description
科大讯飞神经影像疾病预测方案!
Thread pool
Pytorch: saving and exporting models
[today in history] June 23: Turing's birthday; The birth of the founder of the Internet; Reddit goes online
The R language uses the GT package and the gtextras package to display tabular data gracefully and beautifully: gt of the gtextras package_ The sparkline function visualizes the line plot of the group
Code examples of golang goroutine, channel and time
The summary of high concurrency experience under the billion level traffic for many years is written in this book without reservation
ADB 按键名、按键代码数字、按键说明对照表
Advanced development - generic entry basic class test
Six stone programming: the subtlety of application
[tcapulusdb knowledge base] Introduction to tmonitor background one click installation (I)