Other recent Dynamics AX Blog postings

Freitag, Oktober 21, 2005

Release Date of SQL Server 2005

Just in case you didn't know already:
the international release date of Microsoft SQL Server 2005 is November 7th (2005).

Here in Austria (where I live), the release date is November 22nd (2005) and it will be released together with Microsoft Visual Studio .NET 2005.

Unfortunately, I still do not know whether Axapta 3.0 will get a SQL 2005 connection or not..........

Montag, Oktober 17, 2005

The mystery of "index" vs. "index hint"

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.

Tip: On the Axapta 3.0 installation CD, you will find a document called "Performance enhancements using the Cost-Based optimizer" (file name: AX-300-TIP-024-v01.00-ENUS.doc) that will tell you some more things about Axapta and database optimizers.