I have the following tables:
- User that has a non clustered Index on UserName and Active columns.
- Notification that has a non clustered index on the UserId
I don't understand why in the first situation the non-clustered index on the username is used, but non in the second:
I expected for the second situation, that SQL will do a non clustered index seek on the User table, then a Clustered Index Seek on the Notification table.
Link to the execution plan: https://www.brentozar.com/pastetheplan/?id=HyG1Kwm1h
The IX_UserName index is defined as unique and it's also filtered on Active = 1
.