当前位置:网站首页>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
边栏推荐
- leetcode:面試題 08.13. 堆箱子【自頂而下的dfs + memory or 自底而上的排序 + dp】
- leetcode:面试题 08.13. 堆箱子【自顶而下的dfs + memory or 自底而上的排序 + dp】
- 走好数据中台最后一公里,为什么说数据服务 API 是数据中台的标配?
- 多年亿级流量下的高并发经验总结,都毫无保留地写在了这本书中
- Code examples of golang goroutine, channel and time
- Openresty Foundation
- 读书郎通过上市聆讯:平板业务毛利率走低,2021年利润同比下滑11%
- SaaS cloud tool, a sharp tool for change under the industrial Internet
- Golang对JSON文件的写操作
- TQ of R language using tidyquant package_ The transmute function calculates the daily, monthly and weekly returns of a stock. Ggplot2 uses the bar plot to visualize the monthly return data of the stoc
猜你喜欢

Apache commons tool class

Advanced development stage - the thickening of potential suspension wire begins A small step now, a big step next year

leetcode:30. 串联所有单词的子串【Counter匹配 + 剪枝】

get_ edges
![[tcapulusdb knowledge base] tcapulusdb tmonitor module architecture introduction](/img/7b/8c4f1549054ee8c0184495d9e8e378.png)
[tcapulusdb knowledge base] tcapulusdb tmonitor module architecture introduction

再突破!阿里云进入Gartner云AI开发者服务挑战者象限

Innovation strength is recognized again! Tencent security MSS was the pioneer of cloud native security guard in 2022

TensorRT Paser加载onnx 推理使用
NLP 论文领读|改善意图识别的语义表示:有监督预训练中的各向同性正则化方法

How did Tencent's technology bulls complete the overall cloud launch?
随机推荐
二分查找法思路分析
Code implementation of golang binary search method
Leetcode: question d'entrevue 08.13. Empiler la boîte [DFS en haut + mémoire ou tri en bas + DP]
【历史上的今天】6 月 23 日:图灵诞生日;互联网奠基人出生;Reddit 上线
[tcapulusdb knowledge base] Introduction to tmonitor background one click installation (II)
【TcaplusDB知识库】Tmonitor后台一键安装介绍(一)
移动云共筑信创云能力底座,助力中国信创产业发展
ASEMI快恢复二极管RS1M、US1M和US1G能相互代换吗
Thinking analysis of binary search method
如何选择券商?手机开户安全么?
How to quickly respond to changing production management needs?
XML
Zhongda face sketch FERET database (cufsf)
What are the risks of opening a fund account? Is it safe to open an account
openGauss数据库源码解析系列文章—— 密态等值查询技术详解(上)
Code examples of golang goroutine, channel and time
Implementation of golang bubble sort code
Opengauss database source code analysis series articles -- detailed explanation of dense equivalent query technology (Part 1)
2022 Jiufeng primary school (Optics Valley No. 21 primary school) student source survey
Summarize the experience of purchasing Alibaba cloud servers