Optimize channel_updates and node_announcements queries, drop unused indexes#106
Optimize channel_updates and node_announcements queries, drop unused indexes#106TheBlueMatt wants to merge 4 commits intolightningdevkit:mainfrom
Conversation
…indexes Rewrite the "oldest bidirectional update" query to use two explicit LATERAL joins (one per direction, each LIMIT 1) instead of DISTINCT ON (direction), which scanned ~4000 rows per scid through the index. Rewrite the node_announcements reference query and channel_updates reference query to use LATERAL joins instead of DISTINCT ON / subquery patterns, forcing efficient index usage instead of sequential scans. Drop four unused/redundant indexes (schema 15 -> 17): - channel_updates_scid_dir_seen_desc_with_id (unused, backward scan on _asc used instead) - channel_updates_scid_asc_timestamp_desc (unused by any query) - channel_updates_seen (redundant with channel_updates_seen_scid) - node_announcements_seen_pubkey (unused, replaced by _pubkey_seen_desc) - node_announcements_pubkey_timestamp_desc (unused by any query) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
I've assigned @jkczyz as a reviewer! |
|
🔔 1st Reminder Hey @jkczyz! This PR has been waiting for your review. |
|
🔔 2nd Reminder Hey @jkczyz! This PR has been waiting for your review. |
|
🔔 3rd Reminder Hey @jkczyz! This PR has been waiting for your review. |
|
🔔 4th Reminder Hey @jkczyz! This PR has been waiting for your review. |
|
🔔 5th Reminder Hey @jkczyz! This PR has been waiting for your review. |
|
🔔 6th Reminder Hey @jkczyz! This PR has been waiting for your review. |
Speeds up queries pretty well. I'm sure to an SQL person these conversions are obvious but I of course don't know SQL.