Reputation: 41
What is the use of having an index on a Guid column in SQL Server? Indexes sort the rows, as per my knowledge. If Guids are randomly generated and are not sorted how do indexes work on them?
Thanks in advance.
Upvotes: 3
Views: 640
Reputation: 2760
Imagine you have a telephone book with (person,number)
pairs. Is there any reason to sort the book by number
? Obviously not: you will never ask queries which search for persons having number between number1 and number2. BUT: you might want to search for the owner of a particular number. And indexing the number
is the only efficient way to do this.
Likewise, indexing a GUID helps you quickly identify the unique tuple with this value. And an index is necessary for this.
Upvotes: 2