I have the following questions:
- What does
SETCURRENTKEY
actually do? - What is the benefit of
SETCURRENTKEY
? - Why would I use
SETCURRENTKEY
? - When would I use
SETCURRENTKEY
? - What is the advantage of using an index and how do I tie this analogously to the example of an old sorting system of a library?
- What type of database querying efficiency problems does this function solve?
I have been searching all over the internet and the 'IT Pro Developer Help' internal Navision documentation for this poorly documented function and I cannot find a right answer to my questions.
The only thing I know is that SETCURRENTKEY
sets the current key for a record variable and it sorts the recordset based on it. When SETCURRENTKEY
is used with only a few keys, it can improve query performance. I have no idea what is actually happening when a database uses an index versus not using an index.
Someone told me this is how SETCURRENTKEY
works:
It is like the old sorting card system in a library: without
SETCURRENTKEY
you would have to go through each shelf and manually filter out for the book you want. You would find a mix of random books and you would have to say: "No, not this one. Yes, this one". WithSETCURRENTKEY
you can have an index analogous to the old system where you would just go to a book or music CD based on its 'Author' or 'Artist' etc.
That's all fine, but I still can't properly answer my questions.