Reputation: 1701
SQL Server uses binary tree with intermediate and leaf node for search but how it will do this. Ex. If a table employee has two fields
Id bigint
Name varchar(50)
with values such as
Id Name
1 Ashish
2 Amit
3 Bhavin
4 Dinesh
If we have created composite non-clustered index on both of this columns with name as first and Id after this than how it work. Whether intermediate nodes contain 1) A-F 2)G-M ... or something else. Also once name is searched in binary then after this tree has id has intermediate node.
In short how does SQL server search in this type of conditions?
Upvotes: 9
Views: 11071
Reputation: 1
This question is a conceptual one and requires a very straight forward answer You can read this article for a short answer :
Upvotes: 0
Reputation: 66687
How It Works
The database takes the columns specified in a CREATE INDEX command and sorts the values into a special data structure known as a B-tree. A B-tree structure supports fast searches with a minimum amount of disk reads, allowing the database engine to quickly find the starting and stopping points for the query we are using.
For more info, check THIS!
Upvotes: 15