You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/12/18 07:31:32 UTC

[GitHub] [dolphinscheduler] caishunfeng commented on a diff in pull request #13172: [Improvement][api-sql] Optimize the sql for paging query project

caishunfeng commented on code in PR #13172:
URL: https://github.com/apache/dolphinscheduler/pull/13172#discussion_r1051545652


##########
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml:
##########
@@ -87,12 +87,15 @@
         </include>
         ,
         u.user_name as user_name,
-        (SELECT COUNT(*) FROM t_ds_process_definition AS def WHERE def.project_code = p.code) AS def_count,
-        (SELECT COUNT(*) FROM t_ds_process_definition_log def, t_ds_process_instance inst WHERE def.code =
-        inst.process_definition_code and def.version = inst.process_definition_version AND def.project_code = p.code
-        AND inst.state=1 ) as inst_running_count
+        count(distinct def.id) AS def_count,
+        count(distinct inst.id) as inst_running_count
         from t_ds_project p
         left join t_ds_user u on u.id=p.user_id
+        left join t_ds_process_definition def
+        on def.project_code = p.code
+        left join t_ds_process_instance inst
+        on inst.process_definition_code = def.code

Review Comment:
   ```suggestion
           on inst.process_definition_code = def.code and inst.process_definition_version = def.version
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org