The N+1 pattern, one query for the list, then one per row for the related data, is the most common performance bug in small systems. It's also a design smell: it means the data access was written row-first instead of set-first.
The fix is almost always a join or an eager load. Postgres is built to return sets; asking for 500 rows one at a time is asking it to do 500 times the work for the same result.
The habit that prevents it: look at the query count, not just the response time. A page that issues 200 queries is slow even when each is fast, and it gets slower as the data grows.