Hi All
Some of our items have grown to over 450 000 active records each in this table, causing extreme slow performance in the sale order entry. We have traced the query and as soon as you select the item in the sales line, it searches the InventItemPrice table to find the latest active cost.
Query:
SELECT TOP 1 T1.ITEMID,T1.VERSIONID,T1.PRICETYPE,T1.INVENTDIMID,T1.MARKUP,T1.PRICEUNIT,T1.PRICE,T1.PRICECALCID,T1.UNITID,T1.PRICEALLOCATEMARKUP,T1.PRICEQTY,T1.STDCOSTTRANSDATE,T1.STDCOSTVOUCHER,
T1.COSTINGTYPE,T1.ACTIVATIONDATE,T1.MODIFIEDDATETIME,T1.CREATEDDATETIME,T1.RECVERSION,T1.PARTITION,T1.RECID FROM INVENTITEMPRICE T1 WHERE (((T1.PARTITION=5637144576)
AND (T1.DATAAREAID='xxx')) AND (((T1.ITEMID='xxxx') AND (T1.PRICETYPE=0)) AND (T1.ACTIVATIONDATE<='2017-01-12 00:00:00.000'))) AND EXISTS (SELECT TOP 1 2 FROM INVENTDIM T2
WHERE (((T2.PARTITION=5637144576) AND (T2.DATAAREAID='xxx')) AND ((((T2.INVENTDIMID=T1.INVENTDIMID) AND (T2.INVENTSIZEID='')) AND (T2.INVENTCOLORID='')) AND (T2.INVENTSITEID='SITE'))))
ORDER BY T1.ACTIVATIONDATE DESC,T1.CREATEDDATETIME DESC
The query above does not return any results, because there will never be a active cost without a size and colour - but it seems that it still goes through all the records for the item.
My question: Can these records be safely removed or should we rather look to change the query in the sales line?
Using Ax 2012 R2 CU7
Eddie