mirror of
https://github.com/lightningnetwork/lnd.git
synced 2026-08-20 13:27:27 +02:00
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. |
||
|---|---|---|
| .. | ||
| migrations | ||
| queries | ||
| amp_invoices.sql.go | ||
| db.go | ||
| db_custom.go | ||
| db_custom_test.go | ||
| graph.sql.go | ||
| invoice_events.sql.go | ||
| invoices.sql.go | ||
| migration.sql.go | ||
| models.go | ||
| payments.sql.go | ||
| querier.go | ||