Skip to content

Commit

Permalink
sql: Create indexes on group_jobs_inq and group_jobs_running
Browse files Browse the repository at this point in the history
A select on `(group_jobs_inq > 0 OR group_jobs_running > 0)` is done in
the main loop on each daemon. Add two indexes to drastically reduce the
load on the MySQL server.
  • Loading branch information
donald committed Jan 10, 2024
1 parent b93fece commit 9c07722
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mysql/create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ CREATE TABLE IF NOT EXISTS mxq_group (
dependency_of_group INT8 UNSIGNED NULL DEFAULT NULL,

INDEX(group_id),
INDEX(group_name)
INDEX(group_name),
INDEX(group_jobs_inq),
INDEX(group_jobs_running)
) DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS mxq_job (
Expand Down
2 changes: 2 additions & 0 deletions mysql/migrate_018_add_group_indexes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE INDEX group_jobs_inq ON mxq_group(group_jobs_inq);
CREATE INDEX group_jobs_running ON mxq_group(group_jobs_running);

0 comments on commit 9c07722

Please sign in to comment.