From a4f5b139f9627ece5ca5474f76bc04b7369ffcf0 Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Tue, 21 Feb 2023 11:36:23 +0100 Subject: [PATCH] Remove hardcoded index generation --- internal/repository/init.go | 15 --------------- .../repository/migrations/02_add-index.down.sql | 5 +++++ 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/internal/repository/init.go b/internal/repository/init.go index b7d4c6b..f589e81 100644 --- a/internal/repository/init.go +++ b/internal/repository/init.go @@ -19,14 +19,6 @@ import ( "github.com/ClusterCockpit/cc-backend/pkg/schema" ) -// Indexes are created after the job-archive is traversed for faster inserts. -const JobsDbIndexes string = ` - CREATE INDEX job_stats ON job (cluster,subcluster,user); - CREATE INDEX job_by_user ON job (user); - CREATE INDEX job_by_starttime ON job (start_time); - CREATE INDEX job_by_job_id ON job (job_id); - CREATE INDEX job_by_state ON job (job_state); -` const NamedJobInsert string = `INSERT INTO job ( job_id, user, project, cluster, subcluster, ` + "`partition`" + `, array_job_id, num_nodes, num_hwthreads, num_acc, exclusive, monitoring_status, smt, job_state, start_time, duration, walltime, resources, meta_data, @@ -286,13 +278,6 @@ func InitDB() error { return err } - // Create indexes after inserts so that they do not - // need to be continually updated. - if _, err := db.DB.Exec(JobsDbIndexes); err != nil { - log.Warn("Error while creating indices after inserts") - return err - } - log.Printf("A total of %d jobs have been registered in %.3f seconds.\n", i, time.Since(starttime).Seconds()) return nil } diff --git a/internal/repository/migrations/02_add-index.down.sql b/internal/repository/migrations/02_add-index.down.sql index e69de29..6c67b45 100644 --- a/internal/repository/migrations/02_add-index.down.sql +++ b/internal/repository/migrations/02_add-index.down.sql @@ -0,0 +1,5 @@ +DROP INDEX IF EXISTS job_stats; +DROP INDEX IF EXISTS job_by_user; +DROP INDEX IF EXISTS job_by_starttime; +DROP INDEX IF EXISTS job_by_job_id; +DROP INDEX IF EXISTS job_by_state; \ No newline at end of file