writing / / 1 min read

Fixing a slow dashboard without a rewrite

A slow dashboard looked like a backend-language problem. It was N+1 queries and missing indexes.

  • PostgreSQL
  • Performance
  • FastAPI

The operations dashboard was slow enough that rewriting the backend in Rust came up as an option.

Measure before you pick a language

The slowness was I/O-bound, not CPU-bound: the backend spent its time waiting on the database. A faster language does nothing for waiting.

What it actually was

  • N+1 queries. One query for a list, then one more per row.
  • Missing indexes, including trigram indexes (pg_trgm) for text search.

Both are fixed in the database and the query layer. No rewrite needed.

Takeaway

When "the backend is slow", find out whether it is computing or waiting. That single question decided this one.

← back to writing