sql server - Why Len Function Can Use Index? -
i have table 145000 rows. , have not index on it.
when run below sql. found table scan on execute plan expected. generate 6 rows , 3481 logic read.
set statistics io on select columna table len(columna)<>5
then add clustered index on columna , run sql.i found cluster index scan on execute plan. generate 6 rows , 3511 logic read. can understand greater logic read b-tree nodes read.
but confuse me use non-clustered index instead of clustered index on columna , run sql. found index scan on execute plan. generate 6 rows , need 417 logic read!.
i don't think len() function can take advantage of index. why non-clustered index on columna makes less logic read(9 times)?
the len
function can't make "use" of index, index, containing only column, occupy far less space, in entirety, base table does. it's more efficient scan index scan base table.
scanning base table loading of other columns in table though they're not needed satisfy query.