索引优化

This commit is contained in:
sk 2024-06-15 10:33:20 +08:00
parent 2a7ada450a
commit af7572f923
3 changed files with 10 additions and 3 deletions

View File

@ -30,8 +30,9 @@ func CoinLogsCollection(plt string) *mongo.Collection {
c_coinlogrec.EnsureIndex(mgo.Index{Key: []string{"seqno"}, Background: true, Sparse: true})
c_coinlogrec.EnsureIndex(mgo.Index{Key: []string{"gamefreeid"}, Background: true, Sparse: true})
c_coinlogrec.EnsureIndex(mgo.Index{Key: []string{"cointype"}, Background: true, Sparse: true})
c_coinlogrec.EnsureIndex(mgo.Index{Key: []string{"-ts"}, Background: true, Sparse: true})
c_coinlogrec.EnsureIndex(mgo.Index{Key: []string{"ts"}, Background: true, Sparse: true})
c_coinlogrec.EnsureIndex(mgo.Index{Key: []string{"channel"}, Background: true, Sparse: true})
c_coinlogrec.EnsureIndex(mgo.Index{Key: []string{"-ts", "logtype", "cointype", "channel"}, Background: true, Sparse: true})
}
return c_coinlogrec
}

View File

@ -18,14 +18,16 @@ func GameDetailedLogsCollection(plt string) *mongo.Collection {
if s != nil {
c_gamedetailed, first := s.DB().C(model.GameDetailedLogCollName)
if first {
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"platform"}, Background: true, Sparse: true}) // 兼容老代码
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"gameid"}, Background: true, Sparse: true})
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"gamefreeid"}, Background: true, Sparse: true})
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"logid"}, Background: true, Sparse: true})
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"time"}, Background: true, Sparse: true})
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"-time"}, Background: true, Sparse: true})
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"ts"}, Background: true, Sparse: true})
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"-ts"}, Background: true, Sparse: true})
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"matchid"}, Background: true, Sparse: true})
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"-ts", "gameid"}, Background: true, Sparse: true})
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"-ts", "gamefreeid"}, Background: true, Sparse: true})
}
return c_gamedetailed
}

View File

@ -21,6 +21,7 @@ func GamePlayerListLogsCollection(plt string) *mongo.Collection {
if s != nil {
c_gameplayerlistlog, first := s.DB().C(model.GamePlayerListLogCollName)
if first {
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"platform"}, Background: true, Sparse: true}) // 兼容老代码
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"snid"}, Background: true, Sparse: true})
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"channel"}, Background: true, Sparse: true})
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"promoter"}, Background: true, Sparse: true})
@ -31,12 +32,15 @@ func GamePlayerListLogsCollection(plt string) *mongo.Collection {
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"gamefreeid"}, Background: true, Sparse: true})
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"gamedetailedlogid"}, Background: true, Sparse: true})
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"ts"}, Background: true, Sparse: true})
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"-ts"}, Background: true, Sparse: true})
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"time"}, Background: true, Sparse: true})
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"-time"}, Background: true, Sparse: true})
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"name"}, Background: true, Sparse: true})
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"matchid"}, Background: true, Sparse: true})
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"matchtype"}, Background: true, Sparse: true})
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"-ts", "gameid"}, Background: true, Sparse: true})
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"-ts", "gamefreeid"}, Background: true, Sparse: true})
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"-ts", "snid", "gameid"}, Background: true, Sparse: true})
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"-ts", "snid", "gamefreeid"}, Background: true, Sparse: true})
}
return c_gameplayerlistlog
}