Skip to content

Commit

Permalink
Optimize gas outputs query
Browse files Browse the repository at this point in the history
  • Loading branch information
iand committed Nov 19, 2020
1 parent 7f6dd40 commit 05cd973
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions storage/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,15 +596,14 @@ func (d *Database) FindGasOutputsMessages(ctx context.Context, batchSize int, mi
m.gas_fee_cap, m.gas_premium, m.gas_limit, m.method,
r.state_root, r.exit_code,r.gas_used, bh.parent_base_fee
FROM visor_processing_messages pm
JOIN receipts r ON pm.cid = r.message -- don't join receipts on height since it's the height of the receipt
JOIN receipts r ON pm.cid = r.message AND r.height = pm.height + 1
JOIN messages m ON pm.cid = m.cid AND pm.height = m.height
JOIN block_messages bm on pm.cid = bm.message AND pm.height = bm.height
JOIN block_headers bh on bm.block = bh.cid AND bm.height = bh.height
WHERE pm.gas_outputs_completed_at IS null AND
pm.height >= ? AND pm.height <= ?
AND r.height >= ? AND r.height <= ?
AND r.height = m.height + 1
ORDER BY pm.height DESC
LIMIT ?
`, minHeight, maxHeight, minHeight+1, maxHeight+1, batchSize); err != nil {
return nil, err
Expand Down

0 comments on commit 05cd973

Please sign in to comment.