From 4bbc9146b3d78da40523fc3a36eacfd5e59a31e5 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Wed, 12 Jun 2013 12:33:03 +0200 Subject: [PATCH] SONAR-3755 Fix big performance issue on selectChildrenComponentIds query --- .../sonar/core/resource/ResourceMapper.xml | 74 ++++++++++--------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml b/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml index 11cd702ab84..bfaff59ad83 100644 --- a/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml @@ -130,46 +130,50 @@ select children.project_id from snapshots children inner join ( - select rootSnapshot.id, rootSnapshot.root_snapshot_id, rootSnapshot.path from snapshots rootSnapshot - - rootSnapshot.project_id in ( - select p.id from projects p where p.enabled=${_true} - and p.kee in #{componentKey} - ) - and rootSnapshot.islast=${_true} - and rootSnapshot.root_snapshot_id is not null - - ) rootSnapshot on children.root_snapshot_id = rootSnapshot.root_snapshot_id - and - - - children.path LIKE rootSnapshot.path + CAST(rootSnapshot.id AS varchar(15)) + '.%' - - - children.path LIKE concat(rootSnapshot.path, rootSnapshot.id, '.%') - - - children.path LIKE rootSnapshot.path || rootSnapshot.id || '.%' - - + select rootSnapshot.id, rootSnapshot.root_snapshot_id, rootSnapshot.path + from snapshots rootSnapshot + inner join ( + + ) rootProject on rootProject.id = rootSnapshot.project_id + and rootSnapshot.islast=${_true} + and rootSnapshot.root_snapshot_id is not null + ) rootSnapshot on children.root_snapshot_id = rootSnapshot.root_snapshot_id + and + + + children.path LIKE rootSnapshot.path + CAST(rootSnapshot.id AS varchar(15)) + '.%' + + + children.path LIKE concat(rootSnapshot.path, rootSnapshot.id, '.%') + + + children.path LIKE rootSnapshot.path || rootSnapshot.id || '.%' + + union -- project ids of the children of a PRJ/TRK component - select children.project_id from snapshots children - inner join ( - select rootSnapshot.id from snapshots rootSnapshot - - rootSnapshot.project_id in ( - select p.id from projects p where p.enabled=${_true} - and p.kee in #{componentKey} - ) - and rootSnapshot.islast=${_true} - and rootSnapshot.root_snapshot_id is null - - ) rootSnapshot on children.root_snapshot_id = rootSnapshot.id + select children.project_id + from snapshots children + inner join ( + select rootSnapshot.id + from snapshots rootSnapshot + inner join ( + + ) rootProject on rootProject.id = rootSnapshot.project_id + and rootSnapshot.islast=${_true} + and rootSnapshot.root_snapshot_id is null + ) rootSnapshot on children.root_snapshot_id = rootSnapshot.id union -- project id of the component itself - select p.id as project_id from projects p where p.enabled=true + + + + + select p.id from projects p + + p.enabled=${_true} and p.kee in #{componentKey} + -- 2.39.5