SAP BC490 Performance Tuning ---- Basics Index

1. 当需要查询数据库时,我们不但要关注哪些数据被读取,同样要关注搜索数据时的范围.
search range : 为了满足SQL语句需要检查哪些记录. 影响它的有访问策略, 使用的索引, where 子句.
Access strategy: index access,  full table scan. 访问策略基于以下条件由Cost based optimizer

  • Conditions in the WHERE clause of the SQL statement
  • Database indexes of the table(s) affected
  • Selectivity of the table fields contained in the database indexes
  • Size of the table(s) affected

优化计算 是 需要读取的数据块的数量.

2. Architeture of indexes

 1> Primary indexes:  consists of primary key fields ,unique
     Secondary indexes:  unique or non-unique.
table ,index 数据是以data block 形式存于硬盘上的. Index blocks 是以多级的B tree形式来组织的.  Root - branch - Leaf .叶一级含有ROWID指向实际的table block 中的记录.注意的是index record是排序的,而table record不是.  一个索引不能含有过多字段,过多会影响处理选择路径.   ]
 
  2> Access Strategies for Tables
 Index Unique Scan
     Unique index is fully specified using AND after the 'equals' sign  对index中的字段用 = 全部设定.
 Index Range Scan
     Index is not fully specified or not unique   在选择条件中使用索引中的部分字段,或索引不是惟一的.
 Full table scan
     No index isused
     All table blocks are read 整个表被顺序读取 ,在条件中没有使用INDEX字段
 Concatenation
     Indexes are used more than once 索引被多次使用 , 像使用IN 语句时
     Used with OR or IN operation

  3> Indexs administration

  4> Using indexes.
        qualifing index fields form left to right benfits the use of indexes. 在WHERE 子句中指定索引字段的值,最好从左到右依次指定索引字段,  指定的字段组成index search string,  index search string是最好不要出现空当, 并且第一个字段尤其重要,不要给它留空. 可以通过SE11查看index中字段的顺序.

3. 精炼访问DB语句以使用索引:
注:根本在于防止Full table scan, 尽可能采用INDEX来访问,而且在有INDEX访问数据库的时候,避免对INDEX顺序查找,而是促使数据库采用BINARY SEARCH.
1> 如果Primary index字段能满足的话,尽量写全,不要漏掉.
2> 使用CLIENT SPECIFIED 时,一定要指定相应的MANDT字段的值,否则会从全部CLIENT数据中搜索.
3> 对于使用NOT,<>的语句,如果可能的话,尽量使用IN来改写.因为使用NOT,<> 系统不会采用binary search 来查找索引.
4> 对于间隔区间较小的BETWEEN 条件用IN来代替.
     对于LIKE, >,< 来讲,如果可能的话尽量采用 = 来代替.  对于LIKE来说,尽量值的第一个字符不要是通配符.
     在ABAP语句中,通配符(widlcard) , + 代表任意单个字符, * 代表任意个字符.但对于数据库访问,  _ % 被用来作为通配符.
 
4. Rules for index designing
如果指定的一条索引可以确定搜索范围在表的5%之内.它是合适的
表内的索引总量不要太多,一般在5个左右,并且索引之间不要有重复的结构和字段.
索引内的字段不要超过4个,太多会占用内存空间,使数据库有不必要的操作.
The selective fields in an index should be as near to the beginning of the index as possible (see index range scan access strategy). Selective fields are, for example, document number, material number, and customer number. Unselective fields are, for example, client, company code, header account, and plant. 作为选取字段在索引中的位置要尽量靠前. Index range scan.

什么样的字段可以成为selective field, 通过这个字段作为条件可以将搜索缩小到一定范围P113.(BC490_COL62)
Tools:
Tcode: DB02. Database Performance: Tables and Indexes.
DB02----> Tables and Indexes ----> Detail Analysis -----> Table Columns
显示出的列表中有一列Disctinct values,这个值越大说明其selectivity 越大,即可以作为selective field.
selectivity analysis (DB05) is a tool for constructing indexes.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值