Broken snippet
// TicketsService
async list(status: string) {
return this.ticketsRepo.find({ where: { status } }); // no index on status
}
// tickets table: only a primary key index on idTopic
Definition
A missing index causes the query planner to perform a sequential scan over an entire table to satisfy a filter or sort, producing latency that grows roughly linearly with table size instead of staying flat.
In simpler words
Without the right index, a filtered list gets slower and slower as the table grows, even though the code never changed.
This reuses the performance judgment from earlier in this week: recognizing the missing-index smell on a slow, filtered, frequently used endpoint.
Definition
A list endpoint that filters or sorts by a column with no index will scale acceptably in development, where tables are small, and degrade sharply in production, where tables are large, because sequential scan cost grows with row count.
In simpler words
The exact same query gets dramatically slower purely because the table grew. The code did not change; the data did.
A ticket list filtered by status and ordered by a created timestamp, with no index on either column, forces Postgres to read and sort every row on every request.
This bug is easy to miss locally with a few dozen seed rows and only shows up as a production incident once the table holds hundreds of thousands of rows.
Challenge lab
GET /tickets?status=open gets slower every week as the tickets table grows; it was instant in development.
The tickets table has no index on status, so every filtered list performs a full sequential scan that gets more expensive as rows accumulate.
// TicketsService
async list(status: string) {
return this.ticketsRepo.find({ where: { status } }); // no index on status
}
// tickets table: only a primary key index on idTest
At least 10 questions — mix of concept, syntax, practical, and logic. Score ≥ 80% (enforced by the API) to save progress.
Checking your session…
10 questions · concept 3 · syntax 2 · practical 3 · logic 2