-- ============================================================================ -- Migration 002: Add performance indexes -- ============================================================================ -- Descrizione: Aggiunge indici per migliorare performance query detections -- Data: 2025-11-22 -- ============================================================================ -- Indice su blocked per filtrare IP bloccati CREATE INDEX IF NOT EXISTS detections_blocked_idx ON detections(blocked); -- Indice composto per query "IP bloccati recenti" CREATE INDEX IF NOT EXISTS detections_blocked_detected_idx ON detections(blocked, detected_at) WHERE blocked = true; -- Commento descrittivo COMMENT ON INDEX detections_blocked_idx IS 'Index for filtering blocked IPs';