Skip to content

Commit 625cda7

Browse files
committed
feat: add index on 'at' column for monitor_checks to optimize query performance
1 parent 77fc247 commit 625cda7

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/db/schema.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ export const monitorChecks = sqliteTable('monitor_checks', {
269269
// El orden importa: monitor_id primero para poder buscar por partición, `at`
270270
// después para leer las últimas N sin ordenar.
271271
monitorAtIdx: index('monitor_checks_monitor_at_idx').on(t.monitorId, t.at),
272+
// Aparte del compuesto: /api/engineering/live consulta por fecha SIN filtrar
273+
// por monitor ("último sondeo", "cuántos en 24h"), y ahí el compuesto no
274+
// sirve — `at` no es su columna líder. Verificado con EXPLAIN QUERY PLAN.
275+
atIdx: index('monitor_checks_at_idx').on(t.at),
272276
}))
273277

274278
// Caídas agrupadas: del primer fallo al primer éxito posterior. Da el "informe de caídas".

0 commit comments

Comments
 (0)