When SQL Server has a choice of plans, it will compare the cost among a set of execution plans and will choose the cheapest one.
In some cases, even though the cost of seek is slightly higher than the cost of scan, SQL Server Optimize might still choose a seek based plan as demonstrated in the video.
SQL Server may not evaluate all possible plans, there are various stages of optimization and SQL Server will evaluate a subset of plans at these stages.
The below video demonstrates this with hands-on example. SQLTest Tool simulates the hands-on labs for you, no registration necessary. You can practice the online hands-on example while watching the video.
Check out www.sqlvideo.com for additional hands-on videos.
Subscribe to our newsletter: https://newsletter.sqlworkshops.com