(轉(zhuǎn))ABAP 程序性能 小技巧

1、使用where語(yǔ)句
不推薦
Select * from zflight.
Check : zflight-airln = ‘LF’ and zflight-fligh = ‘BW222’.
Endselect.
推薦
Select * from zflight where airln = ‘LF’ and fligh = ‘222’.
Endselect.

2净刮、使用聚合函數(shù)
不推薦
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、使用視圖代替基本表查詢(xún)
不推薦
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、使用批量修改內(nèi)表代替逐行修改
不推薦
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穷蛹、使用二分法查詢(xún),提高查詢(xún)內(nèi)表數(shù)據(jù)速度
不推薦
Read table int_fligh with key airln = ‘LF’.
推薦
Read table int_fligh with key airln = ‘LF’ binary search.

7沐绒、兩個(gè)內(nèi)表添加使用批量增加代替逐行
不推薦
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 statementsSelect 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語(yǔ)句,使查詢(xún)能使用索引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語(yǔ)句
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語(yǔ)句
使用的 ABAP SORT + DELETE ADJACENT DUPLICATES 代替.

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末坯辩,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子崩侠,更是在濱河造成了極大的恐慌漆魔,老刑警劉巖,帶你破解...
    沈念sama閱讀 211,743評(píng)論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件却音,死亡現(xiàn)場(chǎng)離奇詭異改抡,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)系瓢,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,296評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門(mén)阿纤,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人夷陋,你說(shuō)我怎么就攤上這事欠拾∫刃浚” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 157,285評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵藐窄,是天一觀(guān)的道長(zhǎng)资昧。 經(jīng)常有香客問(wèn)我,道長(zhǎng)荆忍,這世上最難降的妖魔是什么格带? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 56,485評(píng)論 1 283
  • 正文 為了忘掉前任,我火速辦了婚禮东揣,結(jié)果婚禮上践惑,老公的妹妹穿的比我還像新娘。我一直安慰自己嘶卧,他們只是感情好尔觉,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,581評(píng)論 6 386
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著芥吟,像睡著了一般侦铜。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上钟鸵,一...
    開(kāi)封第一講書(shū)人閱讀 49,821評(píng)論 1 290
  • 那天钉稍,我揣著相機(jī)與錄音,去河邊找鬼棺耍。 笑死贡未,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的蒙袍。 我是一名探鬼主播俊卤,決...
    沈念sama閱讀 38,960評(píng)論 3 408
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼害幅!你這毒婦竟也來(lái)了消恍?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書(shū)人閱讀 37,719評(píng)論 0 266
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤以现,失蹤者是張志新(化名)和其女友劉穎狠怨,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體邑遏,經(jīng)...
    沈念sama閱讀 44,186評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡佣赖,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,516評(píng)論 2 327
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了无宿。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片茵汰。...
    茶點(diǎn)故事閱讀 38,650評(píng)論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖孽鸡,靈堂內(nèi)的尸體忽然破棺而出蹂午,到底是詐尸還是另有隱情栏豺,我是刑警寧澤,帶...
    沈念sama閱讀 34,329評(píng)論 4 330
  • 正文 年R本政府宣布豆胸,位于F島的核電站奥洼,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏晚胡。R本人自食惡果不足惜灵奖,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,936評(píng)論 3 313
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望估盘。 院中可真熱鬧瓷患,春花似錦、人聲如沸遣妥。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 30,757評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)箫踩。三九已至爱态,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間境钟,已是汗流浹背锦担。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 31,991評(píng)論 1 266
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留慨削,地道東北人洞渔。 一個(gè)月前我還...
    沈念sama閱讀 46,370評(píng)論 2 360
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像缚态,于是被迫代替她去往敵國(guó)和親痘煤。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,527評(píng)論 2 349

推薦閱讀更多精彩內(nèi)容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,309評(píng)論 0 10
  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 9,435評(píng)論 0 23
  • pyspark.sql模塊 模塊上下文 Spark SQL和DataFrames的重要類(lèi): pyspark.sql...
    mpro閱讀 9,448評(píng)論 0 13
  • 今天猿规,我們一家去了公園。春天宙橱,公園里的花,草,美極了姨俩,還有水,有小魚(yú)可好了。我和媽媽情不自禁的玩起了自拍师郑,...
    丟了微笑要怎麼偽裝_eacb閱讀 183評(píng)論 0 0
  • 總是會(huì)在某一個(gè)瞬間环葵,覺(jué)得自己無(wú)比孤獨(dú)。尤其是在某個(gè)特別的時(shí)刻宝冕,找不到可以分享心情的人张遭。比如看了好看的電影,翻翻通訊...
    扶搖而上九萬(wàn)里閱讀 2,053評(píng)論 2 0