I am using go-sql-driver in my go micro services, but I found a strange things that update query is extremely slow sometimes. The code as below:
......
timeCost1 := int64(time.Now().UnixNano())/int64(time.Millisecond)
updateSQL := "updateSQL UPDATE conv SET msg_count = ? , client_msg_count = ? , last_msg_content = ? , last_msg_created_on = ? WHERE id = ?"
// args = [66 33 test 2017-03-29 17:28:29.45927 1489978968]
result, err := db.Exec(updateSQL, args...)
timeCost2 := int64(time.Now().UnixNano())/int64(time.Millisecond)
executeTime = timeCost2 - timeCost1
......
the output sql like this:
UPDATE conv SET msg_num = 66 , agent_msg_num = 33 , last_msg_content = 'test' , last_msg_created_on = '2017-03-29 17:28:29.45927' WHERE id = 1489978968
Sometimes, I found the executeTime
is more than 10 seconds, but I cannot reproduce it, and don't find any slow query in mysql slow_query_log. So I cannot confirm it is mysql problem or go package issue, anyone can give me some good idea? Thanks in advance!