mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-09 15:04:39 +02:00
sqldb+invoices: Optimize invoice fetching when the reference is only a hash
The current sqlc GetInvoice query experiences incremental slowdowns during the migration of large invoice databases, primarily due to its complex predicate set. For this specific use case, a streamlined GetInvoiceByHash function provides a more efficient solution, maintaining near-constant lookup times even with extensive table sizes.
This commit is contained in:
@ -54,6 +54,11 @@ WHERE (
|
||||
GROUP BY i.id
|
||||
LIMIT 2;
|
||||
|
||||
-- name: GetInvoiceByHash :one
|
||||
SELECT i.*
|
||||
FROM invoices i
|
||||
WHERE i.hash = $1;
|
||||
|
||||
-- name: GetInvoiceBySetID :many
|
||||
SELECT i.*
|
||||
FROM invoices i
|
||||
|
Reference in New Issue
Block a user