# Lesson 8: Indexes and why queries get slow Indexes and why queries get slow comes up in almost every real SQL project. We start with the why, then write code together. Read the full lesson: [https://glibcode.net/courses/sql-essentials/lessons/8](https://glibcode.net/courses/sql-essentials/lessons/8) ## Files - `indexes.sql`: EXPLAIN QUERY PLAN before and after an index > **Tip:** Count before you delete: run the same WHERE with `SELECT COUNT(*)` first. > **Tip:** `.mode box` and `.headers on` in sqlite3 make results much easier to read. ## Run it ```sh sqlite3 shop.db < ../../setup/schema.sql sqlite3 shop.db < ../../setup/seed.sql sqlite3 shop.db < indexes.sql ``` ## Exercises See [exercises.md](exercises.md). Ask in the forum once you've tried.