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) "