go-gorm / gorm

The fantastic ORM library for Golang, aims to be developer friendly
https://gorm.io
MIT License
36.78k stars 3.93k forks source link

Updates operation becomes too slow after updating from 1.9 to 1.22 #5545

Closed fangweiisfuckingidiot closed 2 years ago

fangweiisfuckingidiot commented 2 years ago

Your Question

** init ** version-1.9:dbClient, err := gorm.Open("mysql", dsn) version-1.22:dbClient, err := gorm.Open(mysql.Open(dsn), &gorm.Config{ DisableAutomaticPing: true, })

** Updates like ** dbClient.Debug().Model(&records).Updates(map[string]interface{}{}

results version-1.9: [54.05ms] UPDATE test_table SET category = 'fu', consumption = 1, description = 'this is update test 2', ops_engineer = 'menger' WHERE ops_consumptions.id = 1

version-1.22: [96.632ms] [rows:1] UPDATE test_table SET category='yii',consumption=1,description='this is update test',ops_engineer='susu' WHERE id = 1

** Updates like ** version-1.22 dbClient.Debug().Exec()

results version-1.22 [19.685ms] [rows:1] UPDATE test_table SET category = "fun1", consumption = 2, description = "this is update test 3", ops_engineer = "menger" WHERE test_table.id = 1

a631807682 commented 2 years ago

duplicated of https://github.com/go-gorm/gorm/issues/5520