Sunday, March 25, 2007

"index" and "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.ITEMIDThe 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 AUsing "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://axaptafreak.blogspot.com/2005/10/mystery-of-index-vs-index-hint.html

Friday, March 23, 2007

How to refresh FormDataSource in class.

void refreshCaller()
{
common common;
formDatasource common_ds;
;
common = element.args().record();
if (common.RecId)
{
if (common.isFormDataSource())
{
common_ds = common.datasource();
if (common_ds)
{
common_ds.reread();
common_ds.refresh();
}
}
}
}

Tuesday, March 20, 2007

Purchase order prices/amount

This parameter setup exists in both AP paramters and Vendor table for Ax4.
The result of my testing is the system will use the value in the second setup which is the setting in vendor table instead of the first one (AP parameter).
The parameter is by vendor and no more for AP module.
AP->Setup->Parameters->Purchase order prices/amount not functioning accordingly anymore.
(Q: If really not functioning, why is it not taken out?)