SQL Database Performance - Key Question

Toddy_Boy
Member Posts: 232
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
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
0
Best Answer
-
what i mean by "many" is that if you write one function where you call the SETCURRENTKEY multiple times for the same record it will slow down your performance. since you seems worried about it i gave you this hint.
back to you question... if you have a key for "No.","Line No." and SumIndexFields "Amount", it means that it will sum for you the values quickly when you are filtering on the key values. if you setup a odd filter that takes times to be calculated it will return a slow result. therefore i suggested you to create a new key that would improve your sum speed
hope it helps5
Answers
-
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 performance0 -
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 wrong0
-
what i mean by "many" is that if you write one function where you call the SETCURRENTKEY multiple times for the same record it will slow down your performance. since you seems worried about it i gave you this hint.
back to you question... if you have a key for "No.","Line No." and SumIndexFields "Amount", it means that it will sum for you the values quickly when you are filtering on the key values. if you setup a odd filter that takes times to be calculated it will return a slow result. therefore i suggested you to create a new key that would improve your sum speed
hope it helps5
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions