From 6dd0e050ce75a565355a1c9239a4894c1cbfdcfc Mon Sep 17 00:00:00 2001 From: wind Date: Thu, 30 Sep 2021 19:35:28 +0800 Subject: [PATCH] [DS-6433][Improvement] find one command optimize without mybatis-plus (#6434) Co-authored-by: caishunfeng <534328519@qq.com> --- .../org/apache/dolphinscheduler/dao/mapper/CommandMapper.java | 2 +- .../org/apache/dolphinscheduler/dao/mapper/CommandMapper.xml | 3 ++- .../dolphinscheduler/service/process/ProcessService.java | 3 +-- sql/dolphinscheduler_h2.sql | 3 ++- sql/dolphinscheduler_mysql.sql | 3 ++- sql/dolphinscheduler_postgre.sql | 2 ++ 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/CommandMapper.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/CommandMapper.java index c784a23b7c..2bbfb4b7b1 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/CommandMapper.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/CommandMapper.java @@ -56,6 +56,6 @@ public interface CommandMapper extends BaseMapper { * query command page * @return */ - IPage queryCommandPage(IPage page); + List queryCommandPage(@Param("limit") int limit, @Param("offset") int offset); } diff --git a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/CommandMapper.xml b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/CommandMapper.xml index ab7033680f..5b2d6b4d8c 100644 --- a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/CommandMapper.xml +++ b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/CommandMapper.xml @@ -46,6 +46,7 @@ diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java index a36cadc342..4f5058cd1f 100644 --- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java +++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java @@ -308,8 +308,7 @@ public class ProcessService { * @return */ public List findCommandPage(int pageSize, int pageNumber) { - Page commandPage = new Page<>(pageNumber, pageSize); - return commandMapper.queryCommandPage(commandPage).getRecords(); + return commandMapper.queryCommandPage(pageSize, pageNumber * pageSize); } /** diff --git a/sql/dolphinscheduler_h2.sql b/sql/dolphinscheduler_h2.sql index ab1baecb5e..ffa3a3a609 100644 --- a/sql/dolphinscheduler_h2.sql +++ b/sql/dolphinscheduler_h2.sql @@ -327,7 +327,8 @@ CREATE TABLE t_ds_command process_instance_priority int(11) DEFAULT NULL, worker_group varchar(64), environment_code bigint(20) DEFAULT '-1', - PRIMARY KEY (id) + PRIMARY KEY (id), + KEY priority_id_index (process_instance_priority, id) ); -- ---------------------------- diff --git a/sql/dolphinscheduler_mysql.sql b/sql/dolphinscheduler_mysql.sql index f1c7f56af1..8aa1519094 100644 --- a/sql/dolphinscheduler_mysql.sql +++ b/sql/dolphinscheduler_mysql.sql @@ -333,7 +333,8 @@ CREATE TABLE `t_ds_command` ( `worker_group` varchar(64) COMMENT 'worker group', `environment_code` bigint(20) DEFAULT '-1' COMMENT 'environment code', `dry_run` int NULL DEFAULT 0 COMMENT 'dry run flagļ¼š0 normal, 1 dry run', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `priority_id_index` (`process_instance_priority`,`id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; -- ---------------------------- diff --git a/sql/dolphinscheduler_postgre.sql b/sql/dolphinscheduler_postgre.sql index 3054f19141..27f525958e 100644 --- a/sql/dolphinscheduler_postgre.sql +++ b/sql/dolphinscheduler_postgre.sql @@ -258,6 +258,8 @@ CREATE TABLE t_ds_command ( PRIMARY KEY (id) ) ; +create index priority_id_index on t_ds_command (process_instance_priority,id); + -- -- Table structure for table t_ds_datasource --