Adjust indexes on CIF collection
Go Test / test (push) Successful in 24s Details

This commit is contained in:
Fred Boniface 2024-04-23 00:31:03 +01:00
parent 7bd9187e64
commit fe059abd6c
1 changed files with 19 additions and 1 deletions

View File

@ -152,7 +152,7 @@ func RemoveOutdatedServices(cutoff time.Time) (count int64, err error) {
return // Automatically returns names values return // Automatically returns names values
} }
// Creates indexes on the Timetable collection // Creates indexes on the Timetable collection... Index suitability needs checking.
func CreateTimetableIndexes() error { func CreateTimetableIndexes() error {
coll := MongoClient.Database(DatabaseName).Collection(TimetableCollection) coll := MongoClient.Database(DatabaseName).Collection(TimetableCollection)
indexModels := []mongo.IndexModel{ indexModels := []mongo.IndexModel{
@ -164,6 +164,24 @@ func CreateTimetableIndexes() error {
}, },
Options: options.Index().SetName("delete_query"), Options: options.Index().SetName("delete_query"),
}, },
{
Keys: bson.M{
"trainUid": 1,
"scheduleStartDate": 1,
"scheduleEndDate": 1,
"daysRun": 1,
},
Options: options.Index().SetName("find_by_uid"),
},
{
Keys: bson.M{
"headcode": 1,
"scheduleStartDate": 1,
"scheduleEndDate": 1,
"daysRun": 1,
},
Options: options.Index().SetName("find_by_headcode"),
},
} }
_, err := coll.Indexes().CreateMany(context.Background(), indexModels) _, err := coll.Indexes().CreateMany(context.Background(), indexModels)