Browse Source

[Improvement] SQL optimization queryTheHighestPriorityTasks (#13671)

Co-authored-by: chenjiaming <chenjiaming@kezaihui.com>
陈家名 2 years ago
parent
commit
c2d5774790

+ 3 - 3
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskGroupQueueMapper.xml

@@ -112,9 +112,9 @@
         select
         <include refid="baseSql" />
         from t_ds_task_group_queue
-        where priority = (select max(priority) from t_ds_task_group_queue where group_id = #{groupId}
-        and status = #{status} and  in_queue = #{inQueue} and force_start = #{forceStart} ) and group_id = #{groupId}
-        and status = #{status} and  in_queue = #{inQueue} and force_start = #{forceStart} limit 1
+        where group_id = #{groupId} and status = #{status} and  in_queue = #{inQueue} and force_start = #{forceStart}
+        order by priority desc
+        limit 1
     </select>
 
     <select id="queryByTaskId" resultType="org.apache.dolphinscheduler.dao.entity.TaskGroupQueue">