From a2c5bd49ff9958f6d5eacc25688ca795a0127291 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Tue, 23 Apr 2024 20:10:04 +0100 Subject: [PATCH] Improve CIF Indexes --- dbAccess/cif.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/dbAccess/cif.go b/dbAccess/cif.go index 9ef7eec..a206786 100644 --- a/dbAccess/cif.go +++ b/dbAccess/cif.go @@ -154,6 +154,7 @@ func RemoveOutdatedServices(cutoff time.Time) (count int64, err error) { // Creates indexes on the Timetable collection... Index suitability needs checking. func CreateTimetableIndexes() error { + log.Info("Creating timetable indexes") coll := MongoClient.Database(DatabaseName).Collection(TimetableCollection) indexModels := []mongo.IndexModel{ { @@ -163,22 +164,13 @@ func CreateTimetableIndexes() error { {Key: "scheduleStartDate", Value: 1}, }, Options: options.Index().SetName("delete_query"), - }, - { - Keys: bson.D{ - {Key: "trainUid", Value: 1}, - {Key: "scheduleStartDate", Value: 1}, - {Key: "scheduleEndDate", Value: 1}, - {Key: "daysRun", Value: 1}, - }, - Options: options.Index().SetName("find_by_uid"), - }, + }, // The find by UID Query can make use of the delete_query index { Keys: bson.D{ {Key: "headcode", Value: 1}, + {Key: "daysRun", Value: 1}, {Key: "scheduleStartDate", Value: 1}, {Key: "scheduleEndDate", Value: 1}, - {Key: "daysRun", Value: 1}, }, Options: options.Index().SetName("find_by_headcode"), },