sqldb: add index on node & chan policy last_update columns

So that we can have efficient lookups during the "*UpdatesInHorizon"
calls.
This commit is contained in:
Elle Mouton
2025-06-20 14:47:57 +02:00
parent 5bb5b6a260
commit 6aa2933379
2 changed files with 4 additions and 0 deletions

View File

@ -3,6 +3,7 @@ DROP INDEX IF EXISTS nodes_unique;
DROP INDEX IF EXISTS node_extra_types_unique;
DROP INDEX IF EXISTS node_features_unique;
DROP INDEX IF EXISTS node_addresses_unique;
DROP INDEX IF EXISTS node_last_update_idx;
DROP INDEX IF EXISTS source_nodes_unique;
DROP INDEX IF EXISTS channels_node_id_1_idx;
DROP INDEX IF EXISTS channels_node_id_2_idx;
@ -12,6 +13,7 @@ DROP INDEX IF EXISTS channel_features_unique;
DROP INDEX IF EXISTS channel_extra_types_unique;
DROP INDEX IF EXISTS channel_policies_unique;
DROP INDEX IF EXISTS channel_policy_extra_types_unique;
DROP INDEX IF EXISTS channel_policy_last_update_idx;
-- Drop tables in order of reverse dependencies.
DROP TABLE IF EXISTS channel_policy_extra_types;

View File

@ -37,6 +37,7 @@ CREATE TABLE IF NOT EXISTS nodes (
CREATE UNIQUE INDEX IF NOT EXISTS nodes_unique ON nodes (
pub_key, version
);
CREATE INDEX IF NOT EXISTS node_last_update_idx ON nodes(last_update);
-- node_extra_types stores any extra TLV fields covered by a node announcement that
-- we do not have an explicit column for in the nodes table.
@ -273,6 +274,7 @@ CREATE TABLE IF NOT EXISTS channel_policies (
CREATE UNIQUE INDEX IF NOT EXISTS channel_policies_unique ON channel_policies (
channel_id, node_id, version
);
CREATE INDEX IF NOT EXISTS channel_policy_last_update_idx ON channel_policies(last_update);
-- channel_policy_extra_types stores any extra TLV fields covered by a channel
-- update that we do not have an explicit column for in the channel_policies