I have a database table called tbl_event with the non-clustered indexes IDX_Event_Folder and IDX_Event_Time defined as:
CREATE NONCLUSTERED INDEX [IDX_Event_Folder]
ON [dbo].[tbl_event]([nobjectid] ASC)
CREATE NONCLUSTERED INDEX [IDX_Event_Time]
ON [dbo].[tbl_event]([tetime] ASC)
I ran the following simple queries and got the execution plans displayed directly underneath:
Query 1:
SELECT *
FROM tbl_event
WHERE tbl_event.nobjectid = 1410000
ORDER BY tetime

Query 2:
SELECT *
FROM tbl_event
WHERE tbl_event.nobjectid = 1410000

My question is, why is the index on nobjectid never utilized? I would expect there to be an index seek or scan when nobjectid is specified in the where clause of these select statements. Is my understanding of this analysis incorrect?
You say in the comments that there are 18325170 rows currently in the table, only about 30 of them have nobjectid=1410000.
Even if your
IDX_Event_Folderindex was disabled I cannot believe that SQL Server would choose this plan for that amount of rows and the line thickness indicates it thinks it is dealing with maybe 1 row not 18325170!So I’m pretty sure that you must have auto update statistics disabled? If so you will need to update the statistics manually (or preferably enable this option)