How do you read an EXPLAIN plan, and what is the difference between an Index Seek and an Index Scan?
Last updated
An
EXPLAINplan is a tree of operators read bottom-up (children feed parents). Focus on access type, estimated vs actual rows (viaEXPLAIN ANALYZE), and the costliest nodes.Index Seek traverses the B-Tree straight to matching keys (efficient for selective filters). Index Scan reads the whole index (fine only when most rows are needed).
Red flags: full table scans on large tables, scans where a seek was expected (non-SARGable predicate or missing index), and big estimate/actual gaps (stale statistics).
- https://learn.microsoft.com/en-us/sql/relational-databases/showplan-logical-and-physical-operators-reference?view=sql-server-ver17
- https://www.brentozar.com/archive/2019/04/index-scans-arent-always-bad-and-index-seeks-arent-always-great/
- https://learn.microsoft.com/en-us/sql/relational-databases/query-processing-architecture-guide?view=sql-server-ver17
- https://dev.to/mashrulhaque/how-to-read-sql-server-execution-plans-7-things-that-matter-3pnm
- https://www.sqlservercentral.com/articles/why-your-index-isnt-being-used-reading-execution-plans-to-find-the-real-culprit
- https://medium.com/@tolgayildiz91/sql-server-execution-plans-the-ultimate-guide-for-query-performance-tuning-91d6160089e0
- https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/performance/troubleshoot-high-cpu-usage-issues
- https://dev.to/rhuturaj_takle/execution-plans-sql-server-3apj