Our developers have come to us with a problem query that isn’t as fast as they’d like. Using any Stack Overflow database:
CREATE INDEX DisplayName ON dbo.Users(DisplayName); GO SELECT * FROM dbo.Users WHERE LEN(DisplayName) > 35;
It has an index, but SQL Server refuses to use that index in the execution plan:
If we force the index with a query hint, we do indeed get dramatically lower logical reads. In my particular database’s case, the clustered index scan is 141,573 logical reads – but scanning the DisplayName index alone is just 38,641 logical reads.
Your Query Exercise challenges this week