web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

AX 2012 View Not Using Index

(0) ShareShare
ReportReport
Posted on by 485

I have a view that pulls batch properties for on-hand inventory.  The view joins InventSum to InventDim on InventDimId and joins InventBatch on ItemId = InventSum.ItemId and InventBatchId = InventDim.InventBatchId.

If the relation on ItemId is removed, the query performance is good, but could potentially return inaccurate data on batches that are not unique to an item Id.

With the ItemId relation included, the view takes 2-3 minutes to open, which is horrible.

SQL performance analyzer recommends this index be created:

CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [dbo].[INVENTSUM] ([PHYSICALINVENT])
INCLUDE ([ITEMID],[INVENTDIMID],[DATAAREAID],[PARTITION],[RECID])

AX already has an index on ItemId and InventDimId, but it is a clustered alternate key index, which I why I assume SQL is not using it.

If I try to create the index, AX complains that the new one overlaps the existing index.  Also, AX will not allow both ItemId and InventDimId be included.

Any suggestions on how to modify the view so the existing index will be utilized?

or.. suggestions on how to create an index that SQL will recognized and use?

Thanks,

- Brad

I have the same question (0)
  • Verified answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    Actually the suggested index has field PhysicalInvent as a normal column, and ItemId, InventDimId, DataAreaId and Partition as included columns.

    An index that has ItemId and InventDimId is very different so it's not really working with the queries that cause this suggestion to be shown. SQL would definetely use the existing index if it would make sense.

    What kind of queries are you making?

  • Sergei Minozhenko Profile Picture
    23,093 on at

    Hi Brad D,

    Looks like that suggested index is the result of the range in view by PHYSICALINVENT field. Are you selecting all records from view in SQL management or the view is a cross-company view? Usually, if you select data from AX there are additional filters by Partition, and DataAreaId are added and it improves query plans as all indexes created from AX have the first two columns Partition and  DataAreaId (if you don't' specify them explicitly in index).

    How many records you have in InventSum, InventDim and in InventBatch tables?

  • Brad Docimo Profile Picture
    485 on at

    Just skipped over PhysicalInvent when I read the output.  Attention to detail..   : )  That did it.  Thanks for the help.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 662 Super User 2026 Season 1

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 280 Super User 2026 Season 1

#3
Martin Dráb Profile Picture

Martin Dráb 201 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans