sqldb/sqlc: add index on graph_channels(version, id)

This new index greatly improves the speed of the
ListChannelsWithPoliciesPaginated query.
This commit is contained in:
Elle Mouton
2025-07-24 13:41:43 +02:00
parent f7efc15a9e
commit 3eed2f94c1
2 changed files with 2 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ DROP INDEX IF EXISTS graph_channels_node_id_1_idx;
DROP INDEX IF EXISTS graph_channels_node_id_2_idx;
DROP INDEX IF EXISTS graph_channels_unique;
DROP INDEX IF EXISTS graph_channels_version_outpoint_idx;
DROP INDEX IF EXISTS graph_channels_version_id_idx;
DROP INDEX IF EXISTS graph_channel_features_unique;
DROP INDEX IF EXISTS graph_channel_extra_types_unique;
DROP INDEX IF EXISTS graph_channel_policies_unique;

View File

@@ -173,6 +173,7 @@ CREATE TABLE IF NOT EXISTS graph_channels (
-- indexes on the node_id_1 and node_id_2 columns.
CREATE INDEX IF NOT EXISTS graph_channels_node_id_1_idx ON graph_channels(node_id_1);
CREATE INDEX IF NOT EXISTS graph_channels_node_id_2_idx ON graph_channels(node_id_2);
CREATE INDEX IF NOT EXISTS graph_channels_version_id_idx ON graph_channels(version, id);
-- A channel (identified by a short channel id) can only have one active
-- channel announcement per protocol version. We also order the index by