lnd/sqldb/sqlc
Elle Mouton ccbe7d696b
sqldb: add composite indexes for v2 block-height horizon queries
Add composite indexes on graph_nodes and graph_channel_policies for
the upcoming v2 block-height-based horizon queries.

The v2 gossip protocol uses block heights instead of unix timestamps
for ordering node announcements and channel updates. The v2
NodeUpdatesInHorizon and ChanUpdatesInHorizon query paths will
filter on WHERE version = @v AND block_height >= start AND
block_height < end. Without these indexes, those queries would
require full table scans.

For nodes, the index is (version, block_height, pub_key). Including
pub_key covers the ORDER BY (block_height, pub_key) clause and
allows direct cursor seeks for pagination, avoiding an extra sort.

For channel policies, the index is (version, block_height). The
pagination cursor uses a CASE expression across two joined policy
rows so the index cannot cover the ORDER BY — the two leading
columns are sufficient for the range scan.
2026-03-31 09:14:49 +02:00
..
migrations sqldb: add composite indexes for v2 block-height horizon queries 2026-03-31 09:14:49 +02:00
queries graph/db: use exclusive end time for horizon queries per BOLT 07 2026-03-31 09:14:48 +02:00
amp_invoices.sql.go sqlc: update sqlc compiler to 1.29.0 2025-05-25 18:23:35 +02:00
db.go sqlc: update sqlc compiler to 1.29.0 2025-05-25 18:23:35 +02:00
db_custom.go paymentsdb: implement FetchInFlightPayments for sql backend 2026-02-25 08:02:16 +01:00
db_custom_test.go scripts: add sql slices workaround to sqlc gen script 2025-07-22 17:14:55 +02:00
graph.sql.go graph/db: use exclusive end time for horizon queries per BOLT 07 2026-03-31 09:14:48 +02:00
invoice_events.sql.go sqlc: update sqlc compiler to 1.29.0 2025-05-25 18:23:35 +02:00
invoices.sql.go sqldb: remove unused GetInvoice query 2026-03-04 13:04:26 +01:00
migration.sql.go sqlc: update sqlc compiler to 1.29.0 2025-05-25 18:23:35 +02:00
models.go sqldb+payments: add payment_duplicates for legacy duplicate payments 2026-02-25 18:52:32 +01:00
payments.sql.go sqldb+paymentsdb: improve filterpayments efficiency 2026-03-19 12:15:13 +01:00
querier.go sqldb+paymentsdb: improve filterpayments efficiency 2026-03-19 12:15:13 +01:00