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:
Andras Banki-Horvath committed 2025-01-23 09:11:01 +01:00
1 parent b92f57e0ae
commit 94e2724a34
5 files changed
+91 -20

No files matched your search

+5
View File
@@ -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