sqldb: drop redundant and unused invoice indexes
Remove four indexes from the invoices table that either duplicate existing UNIQUE constraint indexes or are never used in WHERE clauses: - invoices_hash_idx: redundant, UNIQUE constraint on hash already creates an implicit index - invoices_payment_addr_idx: redundant, UNIQUE constraint on payment_addr already creates an implicit index - invoices_preimage_idx: unused, preimage is NULL on all new invoices and is never used as a query filter - invoices_settled_at_idx: unused, settled_at is NULL on all pending invoices and is never used as a query filter (settle_index is used instead) Dropping these reduces B-tree working set size, which improves page cache utilization as the invoice table grows.
This commit is contained in:
3 files changed
+25
No files matched your search
@@ -22,4 +22,9 @@ var migrationAdditions = []MigrationConfig{
|
|||||||
// schema. This is optional and can be disabled by the
|
// schema. This is optional and can be disabled by the
|
||||||
// user if necessary.
|
// user if necessary.
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "000012_drop_redundant_invoice_indexes",
|
||||||
|
Version: 15,
|
||||||
|
SchemaVersion: 12,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
CREATE INDEX IF NOT EXISTS invoices_hash_idx ON invoices(hash);
|
||||||
|
CREATE INDEX IF NOT EXISTS invoices_payment_addr_idx ON invoices(payment_addr);
|
||||||
|
CREATE INDEX IF NOT EXISTS invoices_preimage_idx ON invoices(preimage);
|
||||||
|
CREATE INDEX IF NOT EXISTS invoices_settled_at_idx ON invoices(settled_at);
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
-- invoices_hash_idx is redundant: The UNIQUE constraint on invoices(hash)
|
||||||
|
-- already creates an implicit index.
|
||||||
|
DROP INDEX IF EXISTS invoices_hash_idx;
|
||||||
|
|
||||||
|
-- invoices_payment_addr_idx is redundant: The UNIQUE constraint on
|
||||||
|
-- invoices(payment_addr) already creates an implicit index.
|
||||||
|
DROP INDEX IF EXISTS invoices_payment_addr_idx;
|
||||||
|
|
||||||
|
-- invoices_preimage_idx is useless: There are no queries that filter on
|
||||||
|
-- preimage so there is no need to index it.
|
||||||
|
DROP INDEX IF EXISTS invoices_preimage_idx;
|
||||||
|
|
||||||
|
-- invoices_settled_at_idx is useless: settled_at is NULL for all pending
|
||||||
|
-- invoices and is never used as a filter in any query (settle_index is used
|
||||||
|
-- instead).
|
||||||
|
DROP INDEX IF EXISTS invoices_settled_at_idx;
|
||||||
Reference in new issue
Block a user