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
.
Asked by Norbert Forgacs
(101 rep)
Mar 6, 2023, 11:23 AM
Last activity: Mar 6, 2023, 01:56 PM
Last activity: Mar 6, 2023, 01:56 PM