fleet-memory/migrations/001_add_links_composite_index.sql
2025-10-31 14:07:45 +01:00

8 lines
448 B
SQL

-- Migration: Add composite index for spreading activation neighbor queries
-- This index optimizes the WHERE ml.from_unit_id::text = ANY($1) AND ml.weight >= 0.1 query
-- which is used during spreading activation search.
-- Composite index for spreading activation neighbor queries (from_unit_id + weight filter)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_memory_links_from_weight
ON memory_links(from_unit_id, weight DESC)
WHERE weight >= 0.1;