diff --git a/chia/data_layer/data_layer.py b/chia/data_layer/data_layer.py index 87b53589e174..e641568f0bb3 100644 --- a/chia/data_layer/data_layer.py +++ b/chia/data_layer/data_layer.py @@ -299,7 +299,8 @@ async def batch_insert( raise ValueError(f"Singleton with launcher ID {tree_id} is not owned by DL Wallet") t1 = time.monotonic() - batch_hash = await self.data_store.insert_batch(tree_id, changelist, status) + enable_batch_autoinsert = self.config.get("enable_batch_autoinsert", True) + batch_hash = await self.data_store.insert_batch(tree_id, changelist, status, enable_batch_autoinsert) t2 = time.monotonic() self.log.info(f"Data store batch update process time: {t2 - t1}.") # todo return empty node hash from get_tree_root diff --git a/chia/data_layer/data_store.py b/chia/data_layer/data_store.py index 0279158a36dc..e3867973a603 100644 --- a/chia/data_layer/data_store.py +++ b/chia/data_layer/data_store.py @@ -1332,6 +1332,7 @@ async def insert_batch( tree_id: bytes32, changelist: List[Dict[str, Any]], status: Status = Status.PENDING, + enable_batch_autoinsert: bool = True, ) -> Optional[bytes32]: async with self.transaction(): old_root = await self.get_tree_root(tree_id) @@ -1369,7 +1370,7 @@ async def insert_batch( # The key is not referenced in any other operation but this autoinsert, hence the order # of performing these should not matter. We perform all these autoinserts as a batch # at the end, to speed up the tree processing operations. - if key_hash_frequency[hash] == 1: + if key_hash_frequency[hash] == 1 and enable_batch_autoinsert: terminal_node_hash = await self._insert_terminal_node(key, value) pending_autoinsert_hashes.append(terminal_node_hash) continue diff --git a/chia/util/initial-config.yaml b/chia/util/initial-config.yaml index a99fc6443685..f1c902cf529b 100644 --- a/chia/util/initial-config.yaml +++ b/chia/util/initial-config.yaml @@ -687,6 +687,9 @@ data_layer: # separate log file (under logging/data_sql.log). log_sqlite_cmds: False + # Speeds up autoinserts. Disable to perform inserts one by one instead of in a batch. + enable_batch_autoinsert: True + logging: *logging ssl: