From 4d8cc494e18a7fab5a9d737e670cbfcf87b94519 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Wed, 21 Oct 2020 13:53:37 -0400 Subject: [PATCH] add txo_unspent_by_address index --- lbry/db/tables.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lbry/db/tables.py b/lbry/db/tables.py index 22aa14b1e..4c861dd78 100644 --- a/lbry/db/tables.py +++ b/lbry/db/tables.py @@ -159,6 +159,9 @@ pg_add_txo_constraints_and_indexes = [ # for calculating supports on a claim f"CREATE INDEX txo_unspent_supports ON txo (claim_hash) INCLUDE (amount) " f"WHERE spent_height = 0 AND txo_type={TXO_TYPES['support']};", + # for calculating balance + f"CREATE INDEX txo_unspent_by_address ON txo (address) INCLUDE (amount) " + f"WHERE spent_height = 0;", # for finding modified claims in a block range f"CREATE INDEX txo_claim_changes " f"ON txo (height DESC) INCLUDE (claim_hash, txo_hash) "