I'm having a strange (to me) issue with a non clustered index on SQL Server 11.0. I have a quite large table with about 4 million rows. I've created a non clustered index which looks like this
Neither is colum is primary key
I then run the follow queries with different results. One uses the non clustered index but the other does not and I can't figure out why. The only difference I can see is that AggregateEntityId is nullable.
The second query takes about 15 seconds the first takes about 50 milliseconds. Why doesn't the second query use the non clustered index?