Files
cloud-ip-validator/internal/db/migrations/0009_scale_indexes.sql
T

11 lines
544 B
SQL
Raw Normal View History

-- Scale indexes (see docs/changes: FIP scan at scale).
--
-- idx_ip_queue_registry: ListRegistry/ListRegistryPage look up the live
-- ip_queue row of every registry address by registry_id; without an index
-- that was a full scan per address, i.e. O(n^2) with thousands of addresses.
--
-- idx_ip_queue_state_aggregated: paged "recently finished" listings
-- (state filter, newest aggregated_at first).
CREATE INDEX idx_ip_queue_registry ON ip_queue(registry_id);
CREATE INDEX idx_ip_queue_state_aggregated ON ip_queue(state, aggregated_at);