Joining internal tables.
来源:互联网 发布:淘宝如何提高销量 编辑:程序博客网 时间:2024/05/16 06:25
Naive join: loop ITAB1, read ITAB2 w/key
Runtime: 732 microseconds
* Entries: 1000 (ITAB1), 300 (ITAB2)
* Line width: 100
* Both tables sorted by unique key K ascending
LOOP AT ITAB1 INTO WA1.
READ TABLE ITAB2 INTO WA2
WITH KEY K = WA1-K BINARY SEARCH.
IF SY-SUBRC = 0.
" ...
ENDIF.
ENDLOOP.
More sophisticated: use parallel cursors
Runtime: 360 microseconds
* Entries: 1000 (ITAB1), 300 (ITAB2)
* Line width: 100
* Both tables sorted by unique key K ascending
DATA: I TYPE I.
I = 1.
LOOP AT ITAB1 INTO WA1.
do.
READ TABLE ITAB2 INTO WA2 INDEX I.
IF SY-SUBRC <> 0. EXIT. ENDIF.
IF WA2-K < WA1-K.
ADD 1 TO I.
ELSEIF WA2-K = WA1-K.
" ...
ADD 1 TO I.
EXIT.
ELSE.
EXIT.
endif.
enddo.
if sy-subrc <> 0. exit. endif.
ENDLOOP.
Documentation
If ITAB1 has n1 entries and ITAB2 has n2 entries, the time needed for
joining ITAB1 and ITAB2 with the straightforward algorithm is
O( n1 * log2( n2 ) ), whereas the parallel cursor approach takes only
O( n1 + n2 ) time.
The above parallel cursor algorithm assumes that ITAB2 is a secondary
table containing only entries also contained in primary table ITAB1.
If this assumption does not hold, the parallel cursor algorithm
gets slightly more complicated, but its performance characteristics
remain the same.
- Joining internal tables.
- Joining tables in SQLite
- Xen Internal - grant tables
- Intersection of internal tables
- Filling nested internal tables
- Compare two internal tables
- Sorting Internal Tables(内表排序)
- Joining data
- What Are Different Types Of Internal Tables and Their Usage
- SAP DEMO-Internal tables-Operations on Single Lines
- SAP DEMO-Internal tables-Operations on the Whole Table
- Google Considers Joining Eclipse
- The Joining (Episode 122)
- Joining a Tour
- Uva11722 Joining with Friend
- uva11722 Joining with Friend
- Slicing and Joining
- internal
- Intersection of internal tables
- 如何加快熟悉通信协议
- Nested loops
- Flex导出Excel
- 位运算在排序与搜索中的应用(转)
- Joining internal tables.
- ExtJS中的get函数:get,getCmp,getDom,getBody,getDoc
- oracle 表空间的创建
- Building unique sorted hashed tables.
- Part Seq access Hashed vs sorted
- Building unique standard hashed tables
- Proxy模式——结构性模式
- Single Read Sorted vs hashed tables
- RedHat5下安装oracle10g