SQL index changes in 5.0

NavStudent
Member Posts: 399
Hello I was looking at the beta 5.0 and Navision has changed the sql keys.
For example in Item Ledger. They have changed the Navision key
To sql index
Since Navision calls sort by
Source Type,Source No.,Item No.,Variant Code,Posting Date
in sql statement when you use the key, does this cause SQL to do more processing to sort it by that order?
My question is basically does SQL use indexes for sorting?
And how much processing is involved in sorting.
Thank you.
For example in Item Ledger. They have changed the Navision key
Source Type,Source No.,Item No.,Variant Code,Posting Date
To sql index
Source No.,Item No.,Variant Code,Posting Date,Entry No.
Since Navision calls sort by
Source Type,Source No.,Item No.,Variant Code,Posting Date
in sql statement when you use the key, does this cause SQL to do more processing to sort it by that order?
My question is basically does SQL use indexes for sorting?
And how much processing is involved in sorting.
Thank you.
my 2 cents
0
Answers
-
If you only need sorting for a report, and already have a selective index, you can safely create a key and leave the SQL Index of.
Please make sure your users understand that on SQL reports can be significantly slower than on C/Side and that having a Reporting database can become a fine solution.0 -
Mark Brummel wrote:... and that having a Reporting database can become a fine solution.
I remember when one of the great selling points of Navision, was "And you don't need to have a separate reporting database with buckets".David Singleton0 -
I think this is related to what the SQL gurus call "selectivity". A field like source type has the same value hundreds of thousands of entries while a field source no. usually has only a few dozens or hundreds of entries.
Now I don't why is it important that the first field of the key should have high "selectivity" instead of the key itself, but it seems to be...0 -
To get an understanding why first field has to have high selectivity. Think about this. You have a Phone book that is sorted by Last name, then First name. So in order to find by first name, you have to find the last name , and then search through the pages for first name. If the last name was selective (unique enough) you could very fast find the page that starts with last name, and then find first name. But what if the 90 percent of the people were smith?
You would have to look through 90 percent of the book. In computer terms it means means you have to put that into cache and then look through it 90 of the record.0 -
Thanks, that's interesting. So it means searching by indexes is something like a sequential lookup like we do in a phonebook and not something like the searching and sorting algorythms we learned in school? You know like the one if I remember correctly, quickfind or quicksort, to find an element in an array - if it's n elements long, look at the one at the n/2 position, then if it's too small then at the one at (n/2 +n)/2 etc. always halving the array. Such algorythms don't really care much how many fields are there in the key - I think they always take log 2 n time. Funny. Probably the main difference might be that all these algorithms worked on data in memory and the database is on a disk, with a sequential access. Hmmm.... So, I=in a sense, every database is sequential because the head reading the disk doesn't really undestand the nice tuple operations of SQL?0
-
In B-Tree the search time is O(log n). This is just for the first field. After finding the first field, then you need to look for second field within the leaf.
So if all the fields in the first field are the same, then you are scanning through a lot of leafs and looking at each one.0 -
I have done extensive testing on the selectivity and density of standard indexes in NAV on SQL. In SQL 2000 rearranging the clustered indexes for better selectivity did help, but in SQL 2005 it did not seem to make much difference at all. SQL 2005 does not seem to lean so heavily on selectivity as 2000 did. In 2005 the default order works almost just as well as the rearranged order.
The real issue now with 2005 is having dynamic fields in the clustered index. Once a record is inserted into a table with a clustered index the fields in the clustered index should not be updated. This causes serious overhead because if the data in the clustered index changes all non-clustered indexes must be updated to reflect the change. If you look at some of the manf. table clustered index you will find "Status" as the first field, this is not good as the status will change over time and each time it changes the entire clustered index must be updated and all non-clustered indexes.
"getting on my soap box"
I am not sure where the whole "limit the amount of non-clustered indexes" on a table for better performance came from but it is my opinion that this is not accurate. The loss of performance form missing one necessary non-clustered index can have serious performance impact FAR greater than the few milliseconds it take to update and maintain non-clustered indexes. The extra over head from 10 extraneous non-clustered indexes tiny compared to the overhead and performance hit you will take from missing one necessary non-clustered index.
This should be slowly becoming a non-issue as SQL 2005 has a DMV that tracks index usage stats and can tell you exactly what indexes are being used and how often.
"Done Preaching"0 -
You are right in the fact that SQL2005 behaves different than 2000.
The Status field in manufacturing is a real nightmare for performance tuning, been there, done that. :?
In the navision world we definately have a lot to learn on how to make our solution work for SQL
The story about selectivity is strange, because when I was at teched in barcelona last year there was a session specialy about selective indexing on SQL 2005.0 -
Mark Brummel wrote:The story about selectivity is strange, because when I was at teched in barcelona last year there was a session specialy about selective indexing on SQL 2005.0
-
TechEd is THE best way to learn a LOT about other MS technology than Navision.
Although Boston (not Barcelona) had a high quality NAV team I learned the most from the other sessions.
I did however got a change to learn other MS experts about NAV which was pretty cool.0 -
Mark Brummel wrote:TechEd is THE best way to learn a LOT about other MS technology than Navision.
Although Boston (not Barcelona) had a high quality NAV team I learned the most from the other sessions.
I did however got a change to learn other MS experts about NAV which was pretty cool.
Yeah I have to agree, Tech Ed (IT Forums) was very useful, I would recommend it to those Navision experts that want to know what else is going on out there.
And Mark, this is the topic you and I discussed after one of the SQL sessions.David Singleton0 -
In SQL, the clustered index does not need to be the primary key. It should be the most commonly used index. Also, as stated above, it is best if it uses fields that are not modified.There are no bugs - only undocumented features.0
-
[Topic moved from Upcoming version NAV 5.1 forum to SQL Performance forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
[Topic moved from Upcoming version NAV 5.1 forum to SQL General forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
[Topic moved from Upcoming version NAV 5.1 forum to SQL Performance forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
kriki
You can't make your mind huh?0 -
-
-
:oops: I got a little lost at a certain moment. Too many tabs open to move topics from-to.. :oops:Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
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