This is an automated email from the ASF dual-hosted git repository.
wenjun 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 cfd1b19f50 [Improvement-17506][dao] Add index on column
workflow_definition_code for table t_ds_schedules to reduce time cost when
access db (#17513)
cfd1b19f50 is described below
commit cfd1b19f500148542b90845298fc428c8a9ff9bc
Author: unigof <[email protected]>
AuthorDate: Fri Sep 26 17:34:35 2025 +0800
[Improvement-17506][dao] Add index on column workflow_definition_code for
table t_ds_schedules to reduce time cost when access db (#17513)
---
.../dolphinscheduler/dao/mapper/ScheduleMapper.xml | 3 +--
.../src/main/resources/sql/dolphinscheduler_h2.sql | 3 ++-
.../src/main/resources/sql/dolphinscheduler_mysql.sql | 3 ++-
.../main/resources/sql/dolphinscheduler_postgresql.sql | 1 +
.../3.3.2_schema/mysql/dolphinscheduler_ddl.sql | 18 ++++++++++++++++++
.../3.3.2_schema/mysql/dolphinscheduler_dml.sql | 16 ++++++++++++++++
.../3.3.2_schema/postgresql/dolphinscheduler_ddl.sql | 18 ++++++++++++++++++
.../3.3.2_schema/postgresql/dolphinscheduler_dml.sql | 16 ++++++++++++++++
8 files changed, 74 insertions(+), 4 deletions(-)
diff --git
a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.xml
b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.xml
index a1ebe8285a..99c1a59ef6 100644
---
a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.xml
+++
b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.xml
@@ -113,8 +113,7 @@
<select id="filterSchedules"
parameterType="org.apache.dolphinscheduler.dao.entity.Schedule"
- resultType="org.apache.dolphinscheduler.dao.entity.Schedule"
- >
+ resultType="org.apache.dolphinscheduler.dao.entity.Schedule">
SELECT pd.name as workflow_definition_name, p.name as project_name,
<include refid="baseSqlV2">
<property name="alias" value="s"/>
diff --git
a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql
b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql
index 869c6c1ff3..2565eaad7b 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql
@@ -847,7 +847,8 @@ CREATE TABLE t_ds_schedules
environment_code bigint(20) DEFAULT '-1',
create_time datetime NOT NULL,
update_time datetime NOT NULL,
- PRIMARY KEY (id)
+ PRIMARY KEY (id),
+ UNIQUE KEY `uniq_schedules_workflow_definition_code`
(`workflow_definition_code`)
);
-- ----------------------------
diff --git
a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql
b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql
index 6cf0127d2c..3ff392d6a5 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql
@@ -848,7 +848,8 @@ CREATE TABLE `t_ds_schedules` (
`environment_code` bigint(20) DEFAULT '-1' COMMENT 'environment code',
`create_time` datetime NOT NULL COMMENT 'create time',
`update_time` datetime NOT NULL COMMENT 'update time',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `uniq_workflow_definition_code` (`workflow_definition_code`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE = utf8_bin;
-- ----------------------------
diff --git
a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
index 487f5da3a5..148d8b4622 100644
---
a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
+++
b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
@@ -769,6 +769,7 @@ CREATE TABLE t_ds_schedules (
update_time timestamp NOT NULL ,
PRIMARY KEY (id)
);
+CREATE UNIQUE INDEX uniq_schedules_workflow_definition_code ON t_ds_schedules
(workflow_definition_code);
--
-- Table structure for table t_ds_session
diff --git
a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.2_schema/mysql/dolphinscheduler_ddl.sql
b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.2_schema/mysql/dolphinscheduler_ddl.sql
new file mode 100644
index 0000000000..56535458de
--- /dev/null
+++
b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.2_schema/mysql/dolphinscheduler_ddl.sql
@@ -0,0 +1,18 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+ALTER TABLE `t_ds_schedules` ADD UNIQUE KEY `uniq_workflow_definition_code`
(`workflow_definition_code`);
diff --git
a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.2_schema/mysql/dolphinscheduler_dml.sql
b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.2_schema/mysql/dolphinscheduler_dml.sql
new file mode 100644
index 0000000000..4a14f326b9
--- /dev/null
+++
b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.2_schema/mysql/dolphinscheduler_dml.sql
@@ -0,0 +1,16 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
diff --git
a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.2_schema/postgresql/dolphinscheduler_ddl.sql
b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.2_schema/postgresql/dolphinscheduler_ddl.sql
new file mode 100644
index 0000000000..95e406350a
--- /dev/null
+++
b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.2_schema/postgresql/dolphinscheduler_ddl.sql
@@ -0,0 +1,18 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+create unique index uniq_schedules_workflow_definition_code on t_ds_schedules
(workflow_definition_code);
diff --git
a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.2_schema/postgresql/dolphinscheduler_dml.sql
b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.2_schema/postgresql/dolphinscheduler_dml.sql
new file mode 100644
index 0000000000..4a14f326b9
--- /dev/null
+++
b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.2_schema/postgresql/dolphinscheduler_dml.sql
@@ -0,0 +1,16 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/