'Optimizing merge join
Read this article https://bertwagner.com/posts/visualizing-merge-join-internals-and-understanding-their-implications/
There are such phrase:
"If the optimizer added a sort to the upstream merge join though, it may be worth investigating whether it's possible to presort that data so SQL Server doesn't need to sort it on its own. Often times this can be as simple as redefining an included index column to a key column - if you are adding it as the last key column in the index then regression impact is usually minor but you may be able to allow SQL Server to use the merge join without any additional sorting required."
I dont understand. Author offers to add extra column(the one, sorted by sql server itself) to already existing index as a last one? As i understand index is sorted from 1 column to last.
E.G. table with columns "number"(int), "letter"(varchar) will have index ("number", "letter") like
- 1 A
- 1 D
- 3 A
- 3 D
So how does presence of "letter" column in index can save server the trouble of sorting it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
