Optimization

Understanding the EXPLAIN Output

Senior Data Analyst
March 13, 2026
6 min read

The Key Terms

Seq Scan (Sequential Scan)

The database reads every single row. **Slow** for large tables.

Index Scan

The database uses an index to find the rows. **Fast**.

Nested Loop / Hash Join / Merge Join

How the database combines two tables during a JOIN.

What to Look For

1. **Cost**: An estimate of the "Effort." Lower is better.

2. **Rows**: How many rows is the database expecting?

3. **Actual Time**: (With `ANALYZE`) How long did it really take?

Pro Tip

If you see "Seq Scan" on a large table in a WHERE clause, it's time to add an index.

*Day 73: Creating and Using Indexes.*

Ready to put your knowledge into practice?

Join SQL Mastery and learn through interactive exercises.