Browse Source

:zap: Improve blocktree storage performance

Daniel 1 year ago
parent
commit
6fc0e43b77
1 changed files with 5 additions and 0 deletions
  1. 5 0
      kernel/treenode/blocktree.go

+ 5 - 0
kernel/treenode/blocktree.go

@@ -85,6 +85,11 @@ func initDBTables() {
 	if nil != err {
 		logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create table [blocktrees] failed: %s", err)
 	}
+
+	_, err = db.Exec("CREATE INDEX idx_blocktrees_id ON blocktrees(id)")
+	if nil != err {
+		logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create index [idx_blocktrees_id] failed: %s", err)
+	}
 }
 
 func initDBConnection() {