Options

SQL Database Performance - Key Question

Toddy_BoyToddy_Boy Member Posts: 231
Dynamics 2013 SQL 2008 R2

Looking through some slow running queries I've noticed most of them are SELECT SUM() which I believe is equivalent to CALCFIELDS. One of the longest running queries is in CU 7301 InsertWhseEntry which seems to be this statement - WhseEntry2.SETCURRENTKEY("Bin Code","Location Code"); (code is still present in 2016 without the index) then a WhseEntry2.CALCSUMS("Qty. (Base)");

There is a key in standard NAV which includes "Item No." (Bin Code,Location Code,Item No.) however not one that is only Bin and Location

If you run the resultant query through the "Display Estimated Execution Plan" the advice is to create the missing index Bin, Location. On doing this performance seem to noticeably improve.

I've migrated proprietary to SQL in the past and the SQL version performs better when declaring keys with all the fields.

Can anyone throw some light onto why the Bin Code,Location Code,Item No. key would be ignored or have I looked past something?

(There is an overnight job that rebuilds indexes on the Warehouse Entry table.)

Regards

Steve
Life is for enjoying ... if you find yourself frowning you're doing something wrong

Best Answer

Answers

  • Options
    JP_BagdonasJP_Bagdonas Member Posts: 18
    try to add keys to assist you SUM, then it will run much faster

    make sure you dont use many SETCURRENTKEY or SELECTLATESTVERSION or COMMITS, as they slow down performance ;)
  • Options
    Toddy_BoyToddy_Boy Member Posts: 231
    Why would NOT using SETCURRENTKEY help? Is this in general or just when using CALCFIELDS?
    Life is for enjoying ... if you find yourself frowning you're doing something wrong
Sign In or Register to comment.