Keys on Customer ledger entry

BeliasBelias Member Posts: 2,998
edited 2011-01-17 in SQL Performance
I am currently analyzing a database that has performance problems, and digging through the modified tables (i've not the availability of customer data, i'm just doing a first analysis) i've seen this keys in table 21:
all maintained, No VSIFTS
bold lines is a standard key
Customer No.,Batch No.,Posting Date,Document Type,Document No.
Customer No.,Batch No.,Entry No.,Document Type,Document No.

Document Type,Document No.,Document Occurence,Customer No.,Open
Posting Date,Document No.
Document Type,Customer No.,Posting Date,Document No.,Currency Code
Document No.,Document Type,Customer No.
my first thought was that the underlined keys could be unmaintained and then summarized with this one:
Document No.,Customer No.,Batch No.,Document Type
after this i noticed that a lot of keys in this table (which is not "sql friendly", you know), are based on "Document no." and something else.
My (second) thought is about the selectivity of "Document no.", which is usually very high, isn't it?So, why maintain all those keys? :-k
i know that some versions of NAV behaves "stupidly" trying to mach the WHERE and the ORDER BY perfectly, but is there a reason other than this?
EDIT(IMPORTANT): I'm supposing that all the queries use document no. as one of the filters. (which usually happens in NAV)
Thanks in advance
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Sign In or Register to comment.