Browse Source

[Improvement][api-sql] Optimize the sql for paging query project (#13172)

* Optimizing sql

* add version join condition

Co-authored-by: chenjiaming <chenjiaming@kezaihui.com>
3.2.0-release
陈家名 2 years ago committed by GitHub
parent
commit
7643d2840a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml

18
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml

@ -84,15 +84,18 @@
select
<include refid="baseSqlV2">
<property name="alias" value="p"/>
</include>
,
</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
and inst.process_definition_version = def.version
and inst.state = 1
where 1=1
<if test="projectsIds != null and projectsIds.size() > 0">
and p.id in
@ -105,7 +108,8 @@
OR p.description LIKE concat('%', #{searchName}, '%')
)
</if>
order by p.create_time desc
group by p.id
order by p.id desc
</select>
<select id="queryAuthedProjectListByUserId" resultType="org.apache.dolphinscheduler.dao.entity.Project">
select

Loading…
Cancel
Save