Files
beacon-server/db/migrations/086_packets_origin_last_heard.sql
MrAlders0n 70aeca21e7 perf(db): find a node's late hearings through an index on its packets' last hearing
Two bounded ranges instead of an OR across first and last hearing: migration 086
adds idx_packets_origin_last_heard. Planguard entries guard both ranges, and the
node activity test holds the clock still and runs in CI again.
2026-11-19 17:47:14 -05:00

6 lines
337 B
SQL

-- Copyright 2026 Beacon Contributors
-- SPDX-License-Identifier: AGPL-3.0-or-later
-- Node activity finds a node's older packets heard again lately in one range, by their last hearing.
CREATE INDEX CONCURRENTLY idx_packets_origin_last_heard ON packets USING btree (origin_pubkey, last_heard_at DESC) WHERE (origin_pubkey IS NOT NULL);