Why our staging site runs on SQLite

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.

8 comments on “Why our staging site runs on SQLite”

  1. Ben Carter

    Great post. Did you measure this on a real phone as well, or only with throttling in the browser?

  2. Aiko Tanaka

    We tried something similar last year and gave up halfway. Seeing it laid out step by step makes me want to try again.

    1. Priya Nair

      Fair point, and thanks for the thoughtful disagreement. It really depends on the size of the team.

  3. Ravi Menon

    I disagree slightly on the tooling choice, but the reasoning is solid and well explained.

  4. Julia Novak

    I shared this with my team. The list near the end is going straight into our onboarding doc.

  5. Grace Whitmore

    Would love a follow-up in six months to see whether this held up.

  6. Samuel Mensah

    Printed this out for our next retro. Really useful framing.

  7. Grace Whitmore

    Printed this out for our next retro. Really useful framing.

Leave a comment

Your email address will not be published. Required fields are marked *