diff --git a/lbry/wallet/server/db/interface.py b/lbry/wallet/server/db/interface.py index 79475a240..465b1f01a 100644 --- a/lbry/wallet/server/db/interface.py +++ b/lbry/wallet/server/db/interface.py @@ -139,3 +139,6 @@ class BasePrefixDB: def stage_raw_delete(self, key: bytes, value: bytes): self._op_stack.append_op(RevertableDelete(key, value)) + + def estimate_num_keys(self, column_family: 'rocksdb.ColumnFamilyHandle' = None): + return int(self._db.get_property(b'rocksdb.estimate-num-keys', column_family).decode()) diff --git a/lbry/wallet/server/db/prefixes.py b/lbry/wallet/server/db/prefixes.py index 26b105ec0..b88d31551 100644 --- a/lbry/wallet/server/db/prefixes.py +++ b/lbry/wallet/server/db/prefixes.py @@ -144,6 +144,9 @@ class PrefixRow(metaclass=PrefixRowType): def unpack_item(cls, key: bytes, value: bytes): return cls.unpack_key(key), cls.unpack_value(value) + def estimate_num_keys(self) -> int: + return int(self._db.get_property(b'rocksdb.estimate-num-keys', self._column_family).decode()) + class UTXOKey(NamedTuple): hashX: bytes