I have a table with 145000 rows. And have not any index on it.
When I run below sql. I found a table scan on execute plan as expected. It generate six rows and 3481 logic read.
SET STATISTICS IO ON
SELECT columnA FROM table WHERE LEN(columnA)<>5
Then I add a clustered index on columnA and run the sql.I found a cluster index scan on execute plan. It generate six rows and 3511 logic read. I can understand the greater logic read for B-tree nodes read.
But what confuse me is that I use a non-clustered index instead of clustered index on columnA and run the sql. I found an index scan on execute plan. It generate six rows and only need 417 logic read!.
I don't think the len() function can take the advantage of index. But why a non-clustered index on columnA makes less logic read(9 times)?