20.04.2010, 20:05 | #1 |
Участник
|
Rajdip's space: The mystery of "index" vs. "index hint"
Источник: http://rajdipdas.spaces.live.com/Blo...25FA!281.entry
============== In the Axapta community, there is still a big confusion about the "index" and "index hint" statements used in connection with selects. So, what is the Axapta kernel *really* doing: Using "index": when you add the statement "index MyIndex", the Axapta kernel will add an "ORDER BY" with all the fields of the index. Example: select * from InventTable index GroupItemIdx will generate the following SQL statement to the database: SELECT A.ITEMGROUPID, A.ITEMID, A.ITEMNAME,.... FROM INVENTTABLE A ORDER BY A.ITEMGROUPID, A.ITEMID The Index ItemGroupIdx of the InventTable exactly contains the two fields ItemGroupID and ItemId (in that order). Using "index", you still give the control of which index to use to the database optimizer. So, if the optimizer finds a better index to use, it will use it. Using "index hint": when you add the statement "index hint MyIndex", the Axapta kernel will add a statement to instruct the database to use that index and no other one. Example: select * from InventTable index hint GroupItemIdx will generate the following SQL statement to the database: SELECT /*+ INDEX(A I_175GROUPITEMIDX) */ A.ITEMGROUPID, A.ITEMID, A.ITEMNAME,.... FROM INVENTTABLE A Using "index hint", you take away the control of which index to use from the database optimizer. So, if there may be a better index, the database will not use it. Conclusion: Adding the "index" statement to an Axapta select, it does NOT mean that this index will be used by the database. What it DOES mean is that Axapta will send an "order by" to the database. Adding the "index hint" statement to an Axapta select, it DOES mean that this index will be used by the database (and no other one). This rule applies to both the MSSQL and Oracle databases. Источник: http://rajdipdas.spaces.live.com/Blo...25FA!281.entry
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|