From 2de85b012051ef3ffd06c010611e1607abf1d26f Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Thu, 1 Jun 2023 15:40:37 +0200 Subject: [PATCH] Add composite indexes --- internal/repository/migrations/mysql/02_add-index.down.sql | 5 ++++- internal/repository/migrations/mysql/02_add-index.up.sql | 5 ++++- .../repository/migrations/sqlite3/02_add-index.down.sql | 5 ++++- internal/repository/migrations/sqlite3/02_add-index.up.sql | 7 +++++-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/internal/repository/migrations/mysql/02_add-index.down.sql b/internal/repository/migrations/mysql/02_add-index.down.sql index 8129772..1392c45 100644 --- a/internal/repository/migrations/mysql/02_add-index.down.sql +++ b/internal/repository/migrations/mysql/02_add-index.down.sql @@ -2,4 +2,7 @@ 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; +DROP INDEX IF EXISTS job_list; +DROP INDEX IF EXISTS job_list_user; +DROP INDEX IF EXISTS job_list_users; +DROP INDEX IF EXISTS job_list_users_start; diff --git a/internal/repository/migrations/mysql/02_add-index.up.sql b/internal/repository/migrations/mysql/02_add-index.up.sql index 7d8d04a..2524bd9 100644 --- a/internal/repository/migrations/mysql/02_add-index.up.sql +++ b/internal/repository/migrations/mysql/02_add-index.up.sql @@ -2,4 +2,7 @@ CREATE INDEX IF NOT EXISTS job_stats ON job (cluster,subcluster,user); CREATE INDEX IF NOT EXISTS job_by_user ON job (user); CREATE INDEX IF NOT EXISTS job_by_starttime ON job (start_time); CREATE INDEX IF NOT EXISTS job_by_job_id ON job (job_id); -CREATE INDEX IF NOT EXISTS job_by_state ON job (job_state); +CREATE INDEX IF NOT EXISTS job_list ON job (cluster, job_state); +CREATE INDEX IF NOT EXISTS job_list_user ON job (user, cluster, job_state); +CREATE INDEX IF NOT EXISTS job_list_users ON job (user, job_state); +CREATE INDEX IF NOT EXISTS job_list_users_start ON job (start_time, user, job_state); diff --git a/internal/repository/migrations/sqlite3/02_add-index.down.sql b/internal/repository/migrations/sqlite3/02_add-index.down.sql index 8129772..1392c45 100644 --- a/internal/repository/migrations/sqlite3/02_add-index.down.sql +++ b/internal/repository/migrations/sqlite3/02_add-index.down.sql @@ -2,4 +2,7 @@ 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; +DROP INDEX IF EXISTS job_list; +DROP INDEX IF EXISTS job_list_user; +DROP INDEX IF EXISTS job_list_users; +DROP INDEX IF EXISTS job_list_users_start; diff --git a/internal/repository/migrations/sqlite3/02_add-index.up.sql b/internal/repository/migrations/sqlite3/02_add-index.up.sql index 7d8d04a..db9792d 100644 --- a/internal/repository/migrations/sqlite3/02_add-index.up.sql +++ b/internal/repository/migrations/sqlite3/02_add-index.up.sql @@ -1,5 +1,8 @@ CREATE INDEX IF NOT EXISTS job_stats ON job (cluster,subcluster,user); CREATE INDEX IF NOT EXISTS job_by_user ON job (user); CREATE INDEX IF NOT EXISTS job_by_starttime ON job (start_time); -CREATE INDEX IF NOT EXISTS job_by_job_id ON job (job_id); -CREATE INDEX IF NOT EXISTS job_by_state ON job (job_state); +CREATE INDEX IF NOT EXISTS job_by_job_id ON job (job_id, cluster, start_time); +CREATE INDEX IF NOT EXISTS job_list ON job (cluster, job_state); +CREATE INDEX IF NOT EXISTS job_list_user ON job (user, cluster, job_state); +CREATE INDEX IF NOT EXISTS job_list_users ON job (user, job_state); +CREATE INDEX IF NOT EXISTS job_list_users_start ON job (start_time, user, job_state);