Hi,
I'm having serious issues with performance on the invent on hand query in AX2009 (it's basically a RTM version, but on a SP1RU7 binary):
The performance drop issue happens periodically and usually just all of sudden starts during the day. In the morning it may start out with great performance, and a couple of hours later its horrible. Some times the great performance will last days, other times only a few hours. It's quite sporadic.
From the AX SQL profiler log, this query takes about 150 ms.
SELECT SUM(A.POSTEDQTY),SUM(A.POSTEDVALUE),SUM(A.PHYSICALVALUE),SUM(A.DEDUCTED),SUM(A.RECEIVED),SUM(A.RESERVPHYSICAL),SUM(A.RESERVORDERED),SUM(A.REGISTERED),SUM(A.PICKED),SUM(A.ONORDER),SUM(A.ORDERED),SUM(A.ARRIVED),SUM(A.QUOTATIONRECEIPT),SUM(A.QUOTATIONISSUE),SUM(A.AVAILPHYSICAL),SUM(A.AVAILORDERED),SUM(A.PHYSICALINVENT) FROM INVENTSUM A WHERE ((A.DATAAREAID=?) AND ((A.ITEMID=?) AND (A.CLOSED=?))) AND EXISTS (SELECT 'x' FROM INVENTDIM B WHERE ((B.DATAAREAID=?) AND ((B.INVENTDIMID=A.INVENTDIMID) AND (B.INVENTLOCATIONID=?))))
There's one thing that works: Rebuild indexes on InventSum + InventDim (though I'm not sure that indexing InventDim is necessary). That gives an instant performance boost that can last days or perhaps even a week or more. The boost reduces the query to take only 0 ms (measured from AX SQL profiler) and the users notice it immediately.
Now, I tried tinkering with a few things on the SQLServer 2008 R2. I've tried playing with the index fill factor on InventSum and InventDim indexes, setting it to 80. This seemed to have negative effect, so I reset it to 0 (100) on InventDim, but kept it at 80 on InventSum.
The indexes on these tables generally have 0-1% fragmentation.
I have a gut feeling that it might happen after exposing the SQLServer to several heavy queries, but haven't been able to provoke it.
At the moment we have several minimal rebuilt index maintenance jobs running during the day to try to fix it during production hours, but it's really not a good solution.
Any ideas?