EXPLAIN

A statement that shows the plan MySQL will use for a query: which index it picks, how it reads it (const, ref, range, ALL) and roughly how many rows it expects to examine.

Minimal example

sql
EXPLAIN SELECT id, name FROM restaurants
WHERE is_active = 1 AND lat BETWEEN 28.40 AND 28.50
  AND lng BETWEEN 77.00 AND 77.10 AND id > 0
ORDER BY id LIMIT 20;

Learn this concept

Lesson 2.1 · MySQL tables, keys and InnoDB indexes

Used in exercises

Exercise 2.10 · GET /v1/restaurants with a cursor Exercise 2.26 · GET /v1/restaurants: sort by distance Exercise 6.12 · Find and fix the first bottleneck
Prerequisite conceptsComposite index