Finding Long Values Faster: Answers & Discussion


In last week’s Query Exercise, our developers had a query that wasn’t going as fast as they’d like:

CREATE INDEX DisplayName ON dbo.Users(DisplayName); GO SELECT * FROM dbo.Users WHERE LEN(DisplayName) > 35;

The query had an index, but SQL Server was refusing to use the index – even though the query would do way less logical reads if it used the index. You had 3 questions to answer:

Why is SQL Server’s estimated number of rows here so far off? Where’s that estimate coming from? Can you get that estimate to be more accurate? Can you get the logical reads