From 6e43a98176f4f231f306dbbd19077bf3cda7d1b9 Mon Sep 17 00:00:00 2001 From: Jacek Poreda Date: Thu, 16 Mar 2023 16:27:56 +0100 Subject: [PATCH] SONAR-18729 Optimize ce_queue peek query by changing 'not exists' to 'left join' with condition --- .../main/resources/org/sonar/db/ce/CeQueueMapper.xml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/ce/CeQueueMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/ce/CeQueueMapper.xml index 9aebba149fb..0e33cabba68 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/ce/CeQueueMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/ce/CeQueueMapper.xml @@ -182,21 +182,14 @@ left join components c on c.uuid = cq.main_component_uuid and c.qualifier <> 'VW' + left join ce_queue cq2 on cq.main_component_uuid=cq2.main_component_uuid and cq2.status <>'PENDING' where cq.status='PENDING' and cq.started_at is null + and cq2.uuid is null and cq.task_type <> 'ISSUE_SYNC' - and not exists ( - select - 1 - from - ce_queue cq2 - where - cq.main_component_uuid=cq2.main_component_uuid - and cq2.status <> 'PENDING' - ) -- 2.39.5