Optimazation questions

BgestelBgestel Member Posts: 136
edited 2007-12-12 in SQL Performance
I'm Readin a lot of Sql NAV performance related literature lately.

I have the following questions:

Question 1:
- We do not use the variant code in our solution.
I assume that it would not be usefull to have the variant code in de Sql key, or is it? In the standart nav code there are several setranges on this field, since we do not use it the setrange will always result in a statement in the where clause stating variant code="". So is it usefull to have a key on something thats always empty. i dont think so, just want to be sure.

Question 2:
- conserning granularity:
The books en papers i read say that it is good to have the more granular fields in the beginning of the key
so : Document no, document type is better than document type, document no .
Will this slow down selects that only filter on document type??

Lets say the key is document no, posting date, <five more fields>, document type.

Will this slow down selects that only filter on document type??

Question 3:

In 5.0 Ms added some sqlkeys to tbl 32 , why did they choose to manualy add the entry no to every key.

Question 4:

Purely hypothetic:

Lets say that every query done to the sales line has a filter document no in it. And there are never more than 500 lines in an order, invoice ... .
It is possible that additional filters are set. Is it in this case the right way to go to only have a key on document no in the sales line table. (my idea: result set is 500 an sql is fast enougn to sort out the records you need, acording to the extra filters)

Qustion 5:

A good link that explains the various execution plans?

Thanks in advance.
**********************
** SI ** Bert Van Gestel **
**********************

Comments

  • krikikriki Member, Moderator Posts: 9,115
    1) ...
    2) Definitely because SQL has to scan the whole table. But if your table only contains records of the document type you filter for, it won't change anything.
    3) Well, in theory it is not necessary because SQL adds the clustered key to the other keys, so even if it was not there, it is added anyway. But probably they took in consideration that someone might change the clustered index, so in this case it is better to have the entry no. in the key because the order by that Navision sends to SQL always contains the primary key fields at the end. And this can confuse (in some cases) SQL into using a wrong key.
    4) In theory it is enough. But if possible I would add another field (preferably a small one that is used a lot to limit the records to <100). It also depends on how many times you need the index to search on. If it is once a minute, no problem with only "Document No.". If it is once a millisecond, I would add the field for sure.
    5) ...
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.