“It’s frozen,” Maya whispered. “I tried a SELECT * on the entire star_motions table — 400 million rows. I didn’t mean to, but I forgot the WHERE clause.”
With the indexes added, the query rewritten ( SELECT magnitude FROM star_motions WHERE star_id = 'Antares' AND timestamp > NOW() - INTERVAL 7 DAY ), and partitions in place, Maya ran the query again. antaresdatabase
They opened the schema. Maya had been filtering by star_id and timestamp without an index. Leo added a composite index. “Now, Antares doesn’t scan every star — it jumps straight to yours.” “It’s frozen,” Maya whispered
Leo showed Maya the EXPLAIN command. “See here — a full table scan. Antares is screaming for help. Preview your plan before you query.” NOW() - INTERVAL 7 DAY )