Skip to content

Commit 6aa2933

Browse files
committed
sqldb: add index on node & chan policy last_update columns
So that we can have efficient lookups during the "*UpdatesInHorizon" calls.
1 parent 5bb5b6a commit 6aa2933

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

sqldb/sqlc/migrations/000007_graph.down.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ DROP INDEX IF EXISTS nodes_unique;
33
DROP INDEX IF EXISTS node_extra_types_unique;
44
DROP INDEX IF EXISTS node_features_unique;
55
DROP INDEX IF EXISTS node_addresses_unique;
6+
DROP INDEX IF EXISTS node_last_update_idx;
67
DROP INDEX IF EXISTS source_nodes_unique;
78
DROP INDEX IF EXISTS channels_node_id_1_idx;
89
DROP INDEX IF EXISTS channels_node_id_2_idx;
@@ -12,6 +13,7 @@ DROP INDEX IF EXISTS channel_features_unique;
1213
DROP INDEX IF EXISTS channel_extra_types_unique;
1314
DROP INDEX IF EXISTS channel_policies_unique;
1415
DROP INDEX IF EXISTS channel_policy_extra_types_unique;
16+
DROP INDEX IF EXISTS channel_policy_last_update_idx;
1517

1618
-- Drop tables in order of reverse dependencies.
1719
DROP TABLE IF EXISTS channel_policy_extra_types;

sqldb/sqlc/migrations/000007_graph.up.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ CREATE TABLE IF NOT EXISTS nodes (
3737
CREATE UNIQUE INDEX IF NOT EXISTS nodes_unique ON nodes (
3838
pub_key, version
3939
);
40+
CREATE INDEX IF NOT EXISTS node_last_update_idx ON nodes(last_update);
4041

4142
-- node_extra_types stores any extra TLV fields covered by a node announcement that
4243
-- we do not have an explicit column for in the nodes table.
@@ -273,6 +274,7 @@ CREATE TABLE IF NOT EXISTS channel_policies (
273274
CREATE UNIQUE INDEX IF NOT EXISTS channel_policies_unique ON channel_policies (
274275
channel_id, node_id, version
275276
);
277+
CREATE INDEX IF NOT EXISTS channel_policy_last_update_idx ON channel_policies(last_update);
276278

277279
-- channel_policy_extra_types stores any extra TLV fields covered by a channel
278280
-- update that we do not have an explicit column for in the channel_policies

0 commit comments

Comments
 (0)