From 432cf79a702fc077e6e389df9b988a27986a08e2 Mon Sep 17 00:00:00 2001 From: Chris Burr Date: Thu, 19 Feb 2026 15:47:29 +0100 Subject: [PATCH 1/2] fix: Add composite index on (DestinationSite, Queue, Status) to PilotAgents SiteDirector.countPilots() filters on these three columns every scheduling cycle. The existing Statuskey index has GridSite as the leading column and does not cover Queue, resulting in a full table scan. --- src/DIRAC/WorkloadManagementSystem/DB/PilotAgentsDB.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DIRAC/WorkloadManagementSystem/DB/PilotAgentsDB.sql b/src/DIRAC/WorkloadManagementSystem/DB/PilotAgentsDB.sql index 7168e529f74..24cbe5a82b8 100755 --- a/src/DIRAC/WorkloadManagementSystem/DB/PilotAgentsDB.sql +++ b/src/DIRAC/WorkloadManagementSystem/DB/PilotAgentsDB.sql @@ -45,7 +45,8 @@ CREATE TABLE `PilotAgents` ( PRIMARY KEY (`PilotID`), KEY `PilotJobReference` (`PilotJobReference`), KEY `Status` (`Status`), - KEY `Statuskey` (`GridSite`,`DestinationSite`,`Status`) + KEY `Statuskey` (`GridSite`,`DestinationSite`,`Status`), + KEY `idx_dest_queue_status` (`DestinationSite`,`Queue`,`Status`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; From 0ad5ac6cc82436f5c87fe45961544d986b61ea38 Mon Sep 17 00:00:00 2001 From: Chris Burr Date: Thu, 19 Feb 2026 15:48:51 +0100 Subject: [PATCH 2/2] fix: Add index on JobName to Jobs table WorkflowTasks.updateTransformationReservedTasks() looks up jobs by JobName via SELECT JobID FROM Jobs WHERE JobName IN (...). Without an index this requires a full table scan. Also benefits dstat.py and the REST API job-name lookups. --- src/DIRAC/WorkloadManagementSystem/DB/JobDB.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DIRAC/WorkloadManagementSystem/DB/JobDB.sql b/src/DIRAC/WorkloadManagementSystem/DB/JobDB.sql index 6b6704b364e..1bc7ec83b58 100755 --- a/src/DIRAC/WorkloadManagementSystem/DB/JobDB.sql +++ b/src/DIRAC/WorkloadManagementSystem/DB/JobDB.sql @@ -65,7 +65,8 @@ CREATE TABLE `Jobs` ( KEY `MinorStatus` (`MinorStatus`), KEY `ApplicationStatus` (`ApplicationStatus`), KEY `StatusSite` (`Status`,`Site`), - KEY `LastUpdateTime` (`LastUpdateTime`) + KEY `LastUpdateTime` (`LastUpdateTime`), + KEY `JobName` (`JobName`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- ------------------------------------------------------------------------------