ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 提高ABAP性能

提高ABAP性能

原创 Linux操作系统 作者:hzq2010 时间:2011-02-28 22:29:29 0 删除 编辑

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.
推荐
Selectmax( fligh ) from zflight intomaxnu where airln = ‘LF’ and cntry = ‘IN’.

3、使用视图代替基本表查询
不推荐
Select* from zcntry where cntry like ‘IN%’.
Selectsingle * from zflight where cntry = zcntry-cntry and airln = ‘LF’.
Endselect.
推荐
Select* from zcnfl where cntry like ‘IN%’ and airln = ‘LF’.
Endselect.

4、使用INTO table 代替selectendselect
不推荐
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
Selectdistinct
Select… for update
Order by, group by, having clause
Joins
Use the Bypass buffer addition to theselectclause in order to explicitly bypass the buffer whileselecting the data.

9、 使用FOR ALL Entries
不推荐
Loop at int_cntry.
Selectsingle * from zfligh into int_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 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.
Selecta~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 theselection criteria, a where clause can be added to the above inner join.

13、使用sort by 代替order by

14、避免使用SELECTDISTINCT语句
使用的ABAPSORT + DELETE ADJACENT DUPLICATES 代替.

15、内标1批量插入内标2.

INSERT LINES OF ITAB1 [FROM N1] [TO N2] INTO [TABLE] ITAB2 [INDEX IDX].

该语句要求两内表对象具有可以相互转换的行结构。如果不指定行数,则整个内表ITAB1被插入ITAB2中。不指定行数时,ITAB1可以为任意内表,ITAB2必须为索引表,但是如果需要指定起始行N1和终止行N2中的任意一个,则两个内表都必须是索引表。如果ITAB2前指定TABLE 附加项,则ITAB2可以是任意类型内表。使用该方式将一个内表插入到另个中的速度比用循环插入可以快20倍。


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23495244/viewspace-688143/,如需转载,请注明出处,否则将追究法律责任。

上一篇: CONDENSE(去除空格)
下一篇: 函数收集
请登录后发表评论 登录
全部评论

注册时间:2010-03-11

  • 博文量
    196
  • 访问量
    172129