- DB2 数据库会根据DB层的统计值决定 根据查询条件走哪一个索引,某些情况下,由于未知原因,索引会走偏,故程序中可以规定程序走哪一个索引来避免索引走偏的情况发生。
强制走索引的 实例代码如下:
1 SELECT vbeln 2 zorgdn 3 vstel 4 zstaff 5 zvtweg 6 vsbed zacty 7 zlifsk erdat lfdat AS zdtday zebeln 8 INTO CORRESPONDING FIELDS OF TABLE it_likp 9 FROM likp 10 WHERE vbeln IN s_vbeln 11 AND erdat IN s_erdat 12 AND lfart = 'ZCRE' 13 AND vstel IN r_vstel 14 AND zebeln IN s_zebeln 15 AND zorgdn = space 16 AND lfdat IN s_zpldat 17 %_HINTS DB6 '<IXSCAN TABLE=''LIKP'' SAP_INDEX=''Z06'' />'. "#EC CI_HINTS 18 19 %_hints db6 '&SUBSTITUTE LITERALS&'. "#EC CI_HINTS 20 21 where vbeln in s_vbeln 22 and erdat in s_erdat 23 and lfart = 'ZCRE' 24 and vstel in r_vstel 25 and zebeln in s_zebeln 26 and zorgdn = space 27 and lfdat in s_zpldat 28 * %_HINTS DB6 '&max_blocking_factor 5&' "#EC CI_HINTS 29 %_hints db6 '&SUBSTITUTE LITERALS&'.
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/18305.html