Skip to main content
Sign in
Snippets Groups Projects
Commit 09304f9c authored by Jonas Leder's avatar Jonas Leder
Browse files

use batch insert for values, to speedup SQL operation

parent f1a9a8a9
Branches
No related tags found
No related merge requests found
Pipeline #54582 passed
...@@ -42,6 +42,7 @@ func Run() { ...@@ -42,6 +42,7 @@ func Run() {
queue.MainQueue.Enqueue(taskData, 60) queue.MainQueue.Enqueue(taskData, 60)
return return
} }
valuesToInsert := []tables.Value{}
for key, value := range jsonData { for key, value := range jsonData {
valueType := database.GetOrCreateValueType(key) valueType := database.GetOrCreateValueType(key)
dbValue := tables.Value{ dbValue := tables.Value{
...@@ -50,8 +51,9 @@ func Run() { ...@@ -50,8 +51,9 @@ func Run() {
Value: helper.AnyToString(value), Value: helper.AnyToString(value),
Instance: instance, Instance: instance,
} }
database.Db.Create(&dbValue) valuesToInsert = append(valuesToInsert, dbValue)
} }
database.Db.Create(&valuesToInsert)
log.Log.Info("Stored boiler data in database") log.Log.Info("Stored boiler data in database")
}() }()
} }
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment