Our staging environment used to need its own database server. Now it is one file we can copy in a second.
Reading the plan
Every migration we ship can run twice without harm and can be rolled back without restoring a backup. That rule has saved at least one Friday.
- Read the query plan before adding an index
- Put the most selective column first
- Make every migration idempotent
- Back up before, verify after
Premature optimization is the root of all evil, but a missing index is just a bug.
Tomás Reyes
The index we were missing
For staging and small sites we use SQLite. One file is easy to copy, easy to reset, and fast enough for everything we have thrown at it.
The slow page ran eleven queries, and one of them scanned the whole table on every request. The query plan said so in plain words; we had simply never asked.
Great post. Did you measure this on a real phone as well, or only with throttling in the browser?
We tried something similar last year and gave up halfway. Seeing it laid out step by step makes me want to try again.
Fair point, and thanks for the thoughtful disagreement. It really depends on the size of the team.
I disagree slightly on the tooling choice, but the reasoning is solid and well explained.
I shared this with my team. The list near the end is going straight into our onboarding doc.
Would love a follow-up in six months to see whether this held up.
Printed this out for our next retro. Really useful framing.
Printed this out for our next retro. Really useful framing.