zoukankan      html  css  js  c++  java
  • ABAP-索引

    转载:http://blog.sina.com.cn/s/blog_498610450101kbxl.html

         tables: csks.
    
         start-of-selection.
    
           select * up to 10 rows from csks
    
                                  where kokrs <> space and
    
                                        kostl <> space
    
                                  %_hints oracle 'index(csks"J")'.
    
           write: / csks.
    
         endselect.  

    ABAPSQL语句,指定索引(oracle)

     

    ①常用的两种方法:

    1、指定使用全表扫描:%_HINTS ORACLE 'FULL(table_name)'

         表示扫描整个表

    2、指定索引:%_HINTS ORACLE 'INDEX("table_name" " index_name") '

          表示扫描索引表

    在SQL语句优化过程中,经常会用到hint。

     

    Using secondary indexes

     

    Consider the following example: 

    SELECT * FROM SPFLI %_HINTS ORACLE 'INDEX("SPFLI" "SPFLI~001")' ....... ENDSELECT.

    In the above example, 001 is the secondary index of the table SPFLI. It's a well-known fact that the efficient way of retrieving data from the database tables is by using secondary indexes. Many database vendors provide the optimizer hints for the same. From SAP v4.5, optimizer hints can be provided by the %_HINTS parameter. This is dependent on the database systems that support optimizer hints. The point to be noted here is these optimizer hints are not standardized by the SQL standards. Each database vendor is free to provide the optimizer hints.

    Now to know which index to use for our table:

    1. Go to SE11 and there specify the table name

    2. Now from the menu, goto --> indexes

    3. select the required index.

     

    Now suppose that the identifier 001 represents a non-unique secondary index comprising of the columns CITYFROM and CITYTO. The index name should be defined as:

     ~ like SPFLI~001 in the above example.

    The sequence of fields in the WHERE condition is of no relevance in using this optimizers index. If you specify hints incorrectly, ABAP ignores them but doesn't return a syntax error or runtime error.

    The code was written in R/3 4.6C.

     

    Code

     

    Consider the following example:

    REPORT Suresh_test. TABLES: spfli. DATA : t_spfli LIKE spfli OCCURS 0 WITH HEADER LINE. SELECT * FROM spfli INTO TABLE t_spfli %_HINTS ORACLE 'INDEX("SPFLI" "SPFLI~001")'. LOOP AT t_spfli. WRITE :/ t_spfli. ENDLOOP.

    ABAP--如何在SELECT语句中指定索引(example)

    report z_generic_test_program .

     tables: csks.

     start-of-selection.

       select * up to 10 rows from csks

                              where kokrs <> space and

                                    kostl <> space

                              %_hints oracle 'index(csks"J")'.

       write: / csks.

     endselect. 

    Control over FOR ALL ENTRIES Hints

    Under the heading Database Interface Hints, Note 129385 describes the options you have for influencing the database interface by entering hints. The hints are evaluated in the database interface itself and are not passed on to the database.

     

    Starting with kernel Release 4.6B all the above mentioned FOR ALL ENTRIES parameters can be set via such a hint for a single statement. In the example:

      SELECT * FROM [..] FOR ALL ENTRIES IN [..] WHERE [..]

      %_HINTS ORACLE '&prefer_in_itab_opt 1&&prefer_fix_blocking -1&'.

    This way, the boolean parameter 'prefer_in_itab_opt' is explictly set and the boolean parameter 'prefer_fix_blocking' is set to its default value.

     

    FOR ALL ENTRIES hints, like hints are generally only used as

    https://www.ut163.com/for-all-entries-quicken/

     

  • 相关阅读:
    糍粑大叔的独游之旅-战斗!之弹道实现
    攻击判定流程研究: 瀑布算法、圆桌算法、混合算法解析
    GitHub排名TOP30的机器学习开源项目/贪心学院
    学习ES7+ES8
    k8s Ipvs 内部网络自动分配和内部网络一致ip地址,导致ip冲突
    Linux操作系统load average过高,kworker占用较多cpu
    chrome断点调试&&其他技巧
    Mongodb更新数组$pull修饰符 (mongodb 修改器($inc/$set/$unset/$push/$pop/upsert))
    记一次线上Java程序导致服务器CPU占用率过高的问题排除过程
    解决并发问题,数据库常用的两把锁(转)
  • 原文地址:https://www.cnblogs.com/ricoo/p/10170035.html
Copyright © 2011-2022 走看看