pdp: use the reorg-check hash index for the pending message queue panel - #1481
Open
TippyFlitsUK wants to merge 1 commit into
Open
TippyFlitsUK wants to merge 1 commit into
TippyFlitsUK wants to merge 1 commit into
Conversation
The pending eth messages query joins message_sends_eth on the computed key lower(trim(both from signed_hash)). No plain-column index can serve that, so every render of the message queue panel hash-joins against a full scan of message_sends_eth: 8.5 s per render on calibnet SPs with 5.5M+ send rows. Nodes with smaller send tables or an empty pending queue stay under the 5 s slow-log threshold. The matching index already ships: 20260527-pdpv0-reorg-chk-indexes.sql creates idx_message_sends_eth_signed_hash_norm on exactly this expression, partial on send_success = true AND signed_hash IS NOT NULL. A bare LEFT JOIN cannot use it because it must also consider rows outside that predicate. Rewrite the join as a LATERAL probe with send_success = TRUE, making the partial index legal and turning the full scan into one point probe per pending message: 8,459 ms to 64.7 ms on the same node and data, no schema change. Sends with send_success = false are excluded from the join; a wait row is only inserted after successful submission, so no pending wait matches such a send.
LexLuthr
requested changes
Aug 31, 2026
LexLuthr
left a comment
Collaborator
There was a problem hiding this comment.
Do you know why we were doing the LEFT join in the first place? It just doesn't make sense to do a JOIN here.
TippyFlitsUK
force-pushed
the
fix/message-queue-panel-hash-index
branch
from
August 31, 2026 18:39
8a09a37 to
0f456e1
Compare
Collaborator
Author
|
It came in with the panel itself in #1351 - the join is only there to show |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Priority
Not urgent. GUI-only cost; nothing functional is affected.
The problem
The pending eth messages query in
web/api/webrpc/message_queue.gojoinsmessage_sends_ethon the computed keylower(trim(both from mse.signed_hash)). No plain-column index can serve that, so every render of the message queue panel hash-joins against a full scan ofmessage_sends_eth:On my two calibnet SPs (5.5M and 5.7M send rows) that is 8.5 s per render, logged over 1,300 times in one node's recent log window. Nodes with smaller send tables or an empty pending queue stay under the 5 s slow-log threshold, which is why it only surfaces on high-volume nodes.
The matching index already exists:
20260527-pdpv0-reorg-chk-indexes.sqlshipsidx_message_sends_eth_signed_hash_normon exactly this expression, partial onsend_success = true AND signed_hash IS NOT NULL. The panel query cannot use it because a bareLEFT JOINmust also consider rows outside that predicate.The change
Rewrite the join as a
LATERALprobe withsend_success = TRUE, which makes the existing partial index legal and turns the full scan into one point probe per pending message:8,459 ms to 64.7 ms on the same node and data. No schema change. Sends with
send_success = falseare excluded from the join; a wait row is only inserted after successful submission, so no pending wait matches such a send.Verification
Running on both calibnet SPs. Zero slow-SQL warnings since restart; the panel returns identical results.