Hello all. I must start of by apologizing, I cannot post any table definition details per my employer's rules. The actual layout of the tables and indexes that should be built are not the question I have. I am more curious about how execution plans get determined.
I'm doing some ETL work and trying to optimize some coding. I was working on an insert statement last week and saw a covering index was recommended. I did some testing with and without the covering index. It turns out building the covering index and doing the insert took about 50% more time than just doing the insert (9 minutes versus around 13-14). I decided to leave the script as is and just do the inserts. The insert size was around 5 million rows queried from a 50M row table.
Fast forward to today. I have a very similar query to the one I was working with last week which is running much more slowly. It is querying the same table, except it is returning almost all the rows for insert instead of just about 5 million. I went to the query execution plan to see what index it recommended and it did not recommend one. I went back to the query I ran last week to see what index the execution plan recommended, but to my surprise the execution plan no longer recommended an index.
I am relatively new to SQL Server, so forgive me if this is a silly question, but why would this change? Why would the estimated execution plan suggest an index one time, then at another decide it is no longer needed?