Postgres notes I keep coming back to
A short reference for indexes, EXPLAIN, and the habits that prevent slow queries in small apps.

A few notes from running small Postgres databases in production.
Read the plan
sql
EXPLAIN ANALYZE
SELECT * FROM posts WHERE published = true ORDER BY published_at DESC LIMIT 10;
If the plan shows a sequential scan on a large table, an index is usually the answer.
Index what you filter and sort by
- Columns in
WHERE - Columns in
ORDER BY - Foreign keys
Row Level Security stays on for every table, even when the server uses a service key.