Skip to content

Correct severe misconception about SetCurrentKey in the knowledge base - #135

Merged
dcenic merged 1 commit into
mainfrom
bugs/647560FixSetCurrentKeyHallucination
Aug 23, 2026
Merged

Correct severe misconception about SetCurrentKey in the knowledge base#135
dcenic merged 1 commit into
mainfrom
bugs/647560FixSetCurrentKeyHallucination

Conversation

@dcenic

@dcenic dcenic commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

A common misconception is that SetCurrentKey tells SQL Server which index to use for a query. It does not. In Business Central, SetCurrentKey only changes the ORDER BY clause of the generated SQL statement. It does not add an index hint, and the SQL Server query optimizer is free to ignore the named key entirely.

We must therefore fix this knowledge base article and stop asking AL developers to use SetCurrentKey blindly. If you genuinely don't need sorting of the result set, it is detrimental - it hurts your performance and doesn't provide any hint to SQL Server.

@dcenic
dcenic merged commit 9203e3c into main Aug 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants