专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > 行业应用

(转)ABAP 程序性能 小技艺

发布时间:2010-06-06 18:53:49 文章来源:www.iduyao.cn 采编人员:星星草
(转)ABAP 程序性能 小技巧

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’ and cntry = ‘IN’.

3、使用视图代替基本表查询
不推荐
Select * from zcntry where cntry like ‘IN%’.
Select single * from zflight where cntry = zcntry-cntry and airln = ‘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 the performance considerably. The buffer is bypassed while using the following statements
Select distinct
Select … for update
Order by, group by, having clause
Joins
Use the Bypass buffer addition to the select clause in order to explicitly bypass the buffer while selecting the data.

9、 使用FOR ALL Entries
不推荐
Loop at int_cntry.
Select single * from zfligh into int_fligh where 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 should be in the order of the index, either a primary or a secondary index
To choose an index, the optimizer checks the field names specified in the where clause and then uses an index that has the same order of the fields. One more tip is that if a table begins with MANDT, while an index does not, there is a high possibility that the optimizer might not use that index.

11、正确地使用MOVE语句
Instead of using the move-corresponding clause it is advisable to use the move statement instead. Attempt should be made to move entire internal table headers in a single shot, rather than moving the fields one by one.

12、正确地使用inner joinLet us take an example of 2 tables, zairln and zflight. The table zairln has the field airln, which is the airline code and the field lnnam, which is the name of the airline. The table zflight has the field airln, the airline code and other fields which hold the details of the flights that an airline operates.
Since these 2 tables a re logically joined by the airln field, it is 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, a where clause can be added to the above inner join.

13、使用sort by 代替order by

14、避免使用SELECT DISTINCT语句
使用的 ABAP SORT + DELETE ADJACENT DUPLICATES 代替.


友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

  • 《松本行弘的程序全世界》之面向对象

    《松本行弘的程序世界》之面向对象 最近读《SICP》把脑细胞搞死大半,还没看完2章,而且看得也是一知半解,实在是受不了了,...

  • GroovyHelp 3.2.7 GA公布

    GroovyHelp 3.2.7 GA发布 GroovyHelp简介   GroovyHelp是一款Javadoc及Groovydoc搜索查阅软件,它能够帮助Java开发人员以...

  • Velocity在Roller中的使用

    Velocity在Roller中的应用 Velocity是java世界中出现比较早,也比较成熟的、性能比较好的、应用也比较广泛的模板框架。   所...

  • Rpc远程调用框架的设计与兑现(2)

    Rpc远程调用框架的设计与实现(2) 接上: 3   基于Json的前后端数据交互 3.1   轻量级的数据交换形式 3.1.1    什么是Jso...

  • excel 单元格的锁定 以及 JXL的兑现方式

    excel 单元格的锁定 以及 JXL的实现方式 在使用excel表格时,有些列是不希望用户可以修改的,诸如审计日志里面确定的部分,而审计...

  • 仓秤跟散料秤:java连接opc Server

    仓秤和散料秤:java连接opc Server 这三篇都是之前写好的,一直没发。 这次一起发出来吧。   java连接硬件很痛苦,特别是对我这...

  • Rpc远程调用框架的设计与兑现(1)

    Rpc远程调用框架的设计与实现(1) Rpc远程调用框架的设计与实现 1     Rpc远程调用框架设计概述 1.1   研究背景 1.1.1...

  • 集合中的线程安全有关问题

    集合中的线程安全问题 一、why? Java中常用的集合框架推荐使用的三个实现:HashSet\ArrayList\HashMap都是线程不安全的.如...

  • Java定时任务的兑现

    Java定时任务的实现 本例依据Java自身提供的接口实现,通过监听器(Listener)和定时器(Timer)定时执行某个任务(Task)。 MyListener: ...

  • java中log日记的使用

    java中log日志的使用 一、介绍  Log4j是Apache的一个开放源代码项目,通过使用Log4j,我们可以控制日志信息输送的目的地是控...

热门推荐: