0

场景情况:
统计一些数据,分别放入200+个库中
当每个库中的数据量10W以上的时候,有的数据库插入就会变慢
加了慢日志,了解了各个字段的说明,但是没有分析出慢的原因,哪位大佬帮看看
谢谢

代码:
for db_key, insert_data_content := range db_name_to_insert_data{
each_start := time.Now().UnixNano()
err := dbvisit.InsertDataList(map[string]interface{}{“content”: insert_data_content, “dbname”: db_key, “tablename”: SERVER_TRAFFIC_FLOW_LOG_TB})
each_use := (time.Now().UnixNano()-each_start)/1e6
if each_use > 50{
slow_count += 1
adframe.AddMustLog(“—-Insert Server Ip DataList:”, err, db_key, len(insert_data_content), “use time:”,each_use, “(ms)”)
}

插入数据用的自己的框架
mongo慢日志如下:

{
“op” : “insert”,
“ns” : “traffic_flow_log_69.kfw_server_max”,
“command” : {
“insert” : “kfw_server_max”,
“writeConcern” : {
“getLastError” : 1
},
“ordered” : false,
“$db” : “traffic_flow_log_69”
},
“ninserted” : 391,
“keysInserted” : 782,
“numYield” : 0,
“locks” : {
“ParallelBatchWriterMode” : {
“acquireCount” : {
“r” : NumberLong(8)
}
},
“ReplicationStateTransition” : {
“acquireCount” : {
“w” : NumberLong(8)
}
},
“Global” : {
“acquireCount” : {
“r” : NumberLong(1),
“w” : NumberLong(7)
}
},
“Database” : {
“acquireCount” : {
“w” : NumberLong(7)
}
},
“Collection” : {
“acquireCount” : {
“w” : NumberLong(7)
}
},
“Mutex” : {
“acquireCount” : {
“r” : NumberLong(398)
}
}
},
“flowControl” : {
“acquireCount” : NumberLong(7)
},
“storage” : {
“data” : {
“bytesRead” : NumberLong(3683946),
“timeReadingMicros” : NumberLong(2731)
}
},
“responseLength” : 60,
“protocol” : “op_query”,
“millis” : 1562,
“ts” : ISODate(“2020-08-29T01:00:16.585Z”),
“client” : “127.0.0.1”,
“allUsers” : [
{
“user” : “root”,
“db” : “admin”
}
],
“user” : “root@admin”
}

已回答的问题