如何优化ABAP性能
2011-12-09 10:03
267 查看
1、使用where语句
不推荐
Select * from zflight.
Check : zflight-airln = ‘LF’ and zflight-fligh = ‘BW222’.
Endselect.
推荐
Select * from zflight where airln = ‘LF’ and fligh = ‘222’.
Endselect.
2、使用聚合函数
不推荐
Maxnu = 0.
Select * from zflight where airln = ‘LF’ and cntry = ‘IN’.
Check zflight-fligh > maxnu.
Maxnu = zflight-fligh.
Endselect.
推荐
Select max( fligh ) from zflight into maxnu where airln = ‘LF’andcntry = ‘IN’.
3、使用视图代替基本表查询
不推荐
Select * from zcntry where cntry like ‘IN%’.
Select single * from zflight where cntry = zcntry-cntry andairln= ‘LF’.
Endselect.
推荐
Select * from zcnfl where cntry like ‘IN%’ and airln = ‘LF’.
Endselect.
4、使用INTO table 代替select endselect
不推荐
Refresh: int_fligh.
Select * from zflight into int_fligh.
Append int_fligh. Clear int_fligh.
Endselect.
推荐
Refresh: int_fligh.
Select * from zflight into table int_fligh.
5、使用批量修改内表代替逐行修改
不推荐
Loop at int_fligh.
If int_fligh-flag is initial.
Int_fligh-flag = ‘X’.
Endif.
Modify int_fligh.
Endloop.
推荐
Int_fligh-flag = ‘X’.
Modify int_fligh transporting flag where flag is initial.
6、使用二分法查询,提高查询内表数据速度
不推荐
Read table int_fligh with key airln = ‘LF’.
推荐
Read table int_fligh with key airln = ‘LF’ binary search.
7、两个内表添加使用批量增加代替逐行
不推荐
Loop at int_fligh1.
Append int_fligh1 to int_fligh2.
Endloop.
推荐
Append lines of int_fligh1 to int_fligh2.
8、使用table buffering
Use of buffered tables is recommended to improve theperformanceconsiderably. The buffer is bypassed while using thefollowingstatementsSelect distinct
Select … for update
Order by, group by, having clause
Joins
Use the Bypass buffer addition to the select clause in ordertoexplicitly bypass the buffer while selecting the data.
9、 使用FOR ALL Entries
不推荐
Loop at int_cntry. Select single * from zfligh intoint_flighwhere cntry = int_cntry-cntry. Append int_fligh.Endloop.
推荐
Select * from zfligh appending table int_fligh
For all entries in int_cntry
Where cntry = int_cntry-cntry.
10、正确地使用where语句,使查询能使用索引
When a base table has multiple indices, the where clause shouldbein the order of the index, either a primary or a secondaryindex
To choose an index, the optimizer checks the field namesspecifiedin the where clause and then uses an index that has thesame orderof the fields. One more tip is that if a table beginswith MANDT,while an index does not, there is a high possibilitythat theoptimizer
might not use that index.
11、正确地使用MOVE语句
Instead of using the move-corresponding clause it is advisabletouse the move statement instead. Attempt should be made tomoveentire internal table headers in a single shot, rather thanmovingthe fields one by one.
12、正确地使用inner join
Let us take an example of 2 tables, zairln and zflight. Thetablezairln has the field airln, which is the airline code and thefieldlnnam, which is the name of the airline. The table zflight hasthefield airln, the airline code and other fields which holdthedetails
of the flights that an airline operates.
Since these 2 tables a re logically joined by the airln field,itis advisable to use the inner join.
Select a~airln a~lnnam b~fligh b~cntry into table int_airdet
From zairln as a inner join zflight as b on a~airln =b~airln.
In order to restrict the data as per the selection criteria,awhere clause can be added to the above inner join.
13、使用sort by 代替order by
14、避免使用SELECT DISTINCT语句
使用的 ABAP SORT + DELETE ADJACENT DUPLICATES 代替.
不推荐
Select * from zflight.
Check : zflight-airln = ‘LF’ and zflight-fligh = ‘BW222’.
Endselect.
推荐
Select * from zflight where airln = ‘LF’ and fligh = ‘222’.
Endselect.
2、使用聚合函数
不推荐
Maxnu = 0.
Select * from zflight where airln = ‘LF’ and cntry = ‘IN’.
Check zflight-fligh > maxnu.
Maxnu = zflight-fligh.
Endselect.
推荐
Select max( fligh ) from zflight into maxnu where airln = ‘LF’andcntry = ‘IN’.
3、使用视图代替基本表查询
不推荐
Select * from zcntry where cntry like ‘IN%’.
Select single * from zflight where cntry = zcntry-cntry andairln= ‘LF’.
Endselect.
推荐
Select * from zcnfl where cntry like ‘IN%’ and airln = ‘LF’.
Endselect.
4、使用INTO table 代替select endselect
不推荐
Refresh: int_fligh.
Select * from zflight into int_fligh.
Append int_fligh. Clear int_fligh.
Endselect.
推荐
Refresh: int_fligh.
Select * from zflight into table int_fligh.
5、使用批量修改内表代替逐行修改
不推荐
Loop at int_fligh.
If int_fligh-flag is initial.
Int_fligh-flag = ‘X’.
Endif.
Modify int_fligh.
Endloop.
推荐
Int_fligh-flag = ‘X’.
Modify int_fligh transporting flag where flag is initial.
6、使用二分法查询,提高查询内表数据速度
不推荐
Read table int_fligh with key airln = ‘LF’.
推荐
Read table int_fligh with key airln = ‘LF’ binary search.
7、两个内表添加使用批量增加代替逐行
不推荐
Loop at int_fligh1.
Append int_fligh1 to int_fligh2.
Endloop.
推荐
Append lines of int_fligh1 to int_fligh2.
8、使用table buffering
Use of buffered tables is recommended to improve theperformanceconsiderably. The buffer is bypassed while using thefollowingstatementsSelect distinct
Select … for update
Order by, group by, having clause
Joins
Use the Bypass buffer addition to the select clause in ordertoexplicitly bypass the buffer while selecting the data.
9、 使用FOR ALL Entries
不推荐
Loop at int_cntry. Select single * from zfligh intoint_flighwhere cntry = int_cntry-cntry. Append int_fligh.Endloop.
推荐
Select * from zfligh appending table int_fligh
For all entries in int_cntry
Where cntry = int_cntry-cntry.
10、正确地使用where语句,使查询能使用索引
When a base table has multiple indices, the where clause shouldbein the order of the index, either a primary or a secondaryindex
To choose an index, the optimizer checks the field namesspecifiedin the where clause and then uses an index that has thesame orderof the fields. One more tip is that if a table beginswith MANDT,while an index does not, there is a high possibilitythat theoptimizer
might not use that index.
11、正确地使用MOVE语句
Instead of using the move-corresponding clause it is advisabletouse the move statement instead. Attempt should be made tomoveentire internal table headers in a single shot, rather thanmovingthe fields one by one.
12、正确地使用inner join
Let us take an example of 2 tables, zairln and zflight. Thetablezairln has the field airln, which is the airline code and thefieldlnnam, which is the name of the airline. The table zflight hasthefield airln, the airline code and other fields which holdthedetails
of the flights that an airline operates.
Since these 2 tables a re logically joined by the airln field,itis advisable to use the inner join.
Select a~airln a~lnnam b~fligh b~cntry into table int_airdet
From zairln as a inner join zflight as b on a~airln =b~airln.
In order to restrict the data as per the selection criteria,awhere clause can be added to the above inner join.
13、使用sort by 代替order by
14、避免使用SELECT DISTINCT语句
使用的 ABAP SORT + DELETE ADJACENT DUPLICATES 代替.
相关文章推荐
- app性能优化之如何计算apk的启动时间
- 第117课: Spark Streaming性能优化:如何最大程度的确保Spark Cluster和Kafka链接的稳
- 如何调整ABAP程序的性能
- ASP.NET如何进行性能优化的问题,看一老兄的建议!【转】
- Android性能优化之如何避免Overdraw
- 请画出一个抓虫系统的架构图并说明你的爬虫需要如何优化来提升性能
- Web前端性能优化——如何提高页面加载速度
- sap abap 性能优化(一)
- 如何利用MySQL设置远程数据库以优化站点性能
- 数据库中经常分组查询的表如何做性能优化(group by)
- Java Jdbc减少交互提升批量处理性能,到底该如何优化才好?
- 如何优化eclipse?eclipse启动很卡,很慢?性能不好?
- 标题: 优化 Java 垃圾收集的性能——如何利用 IBM Java 虚拟机检测和解决垃圾收集问题
- 如何修复Outlook 2007源文件.PST及性能优化补丁
- 如何调整ABAP程序的性能
- 如何调整ABAP程序的性能(续)
- 如何优化JAVA程序设计和编码,提高JAVA性能
- MySql学习(七) —— 查询性能优化 深入理解MySql如何执行查询
- java gc的工作原理、如何优化GC的性能、如何和GC进行有效的交互
- 如何快速优化手游性能问题?从UGUI优化说起