This is an automated email from the ASF dual-hosted git repository.

leonbao pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 6dd0e05  [DS-6433][Improvement] find one command optimize without 
mybatis-plus (#6434)
6dd0e05 is described below

commit 6dd0e050ce75a565355a1c9239a4894c1cbfdcfc
Author: wind <[email protected]>
AuthorDate: Thu Sep 30 19:35:28 2021 +0800

    [DS-6433][Improvement] find one command optimize without mybatis-plus 
(#6434)
    
    Co-authored-by: caishunfeng <[email protected]>
---
 .../java/org/apache/dolphinscheduler/dao/mapper/CommandMapper.java     | 2 +-
 .../resources/org/apache/dolphinscheduler/dao/mapper/CommandMapper.xml | 3 ++-
 .../org/apache/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 c784a23..2bbfb4b 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<Command> {
      * query command page
      * @return
      */
-    IPage<Command> queryCommandPage(IPage<Command> page);
+    List<Command> 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 ab70336..5b2d6b4 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 @@
     <select id="queryCommandPage" 
resultType="org.apache.dolphinscheduler.dao.entity.Command">
         select *
         from t_ds_command
-        order by update_time asc
+        order by process_instance_priority, id asc
+        limit #{limit} offset #{offset}
     </select>
 </mapper>
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 a36cadc..4f5058c 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<Command> findCommandPage(int pageSize, int pageNumber) {
-        Page<Command> 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 ab1baec..ffa3a3a 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 f1c7f56..8aa1519 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 3054f19..27f5259 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
 --

Reply via email to