Browse Source

[Bug] [dolphinscheduler-api] The pages of project management, workflow instance and task instance are accessed slowly #7061 (#7139)

1、I found that the SQL behind this interface is very slow. The main table is large, but there is no index to use. By add the index, the all mode in the query plan can be changed into a more efficient ref mode. If this optimization still fails to meet the requirements, please contact me and I will continue to optimize。
2、modify index start_time_index in init script and upgrade scripts.
3.0.0/version-upgrade
GaoTianDuo 3 years ago committed by GitHub
parent
commit
ed9fca6c97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql
  2. 2
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgre.sql
  3. 2
      dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_ddl.sql
  4. 3
      dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_ddl.sql

2
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql

@ -600,7 +600,7 @@ CREATE TABLE `t_ds_process_instance` (
`next_process_instance_id` int(11) DEFAULT '0' COMMENT 'serial queue next processInstanceId', `next_process_instance_id` int(11) DEFAULT '0' COMMENT 'serial queue next processInstanceId',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `process_instance_index` (`process_definition_code`,`id`) USING BTREE, KEY `process_instance_index` (`process_definition_code`,`id`) USING BTREE,
KEY `start_time_index` (`start_time`) USING BTREE KEY `start_time_index` (`start_time`,`end_time`) USING BTREE,
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
-- ---------------------------- -- ----------------------------

2
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgre.sql

@ -507,7 +507,7 @@ CREATE TABLE t_ds_process_instance (
) ; ) ;
create index process_instance_index on t_ds_process_instance (process_definition_code,id); create index process_instance_index on t_ds_process_instance (process_definition_code,id);
create index start_time_index on t_ds_process_instance (start_time); create index start_time_index on t_ds_process_instance (start_time,end_time);
-- --
-- Table structure for table t_ds_project -- Table structure for table t_ds_project

2
dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_ddl.sql

@ -387,6 +387,8 @@ alter table t_ds_process_instance add var_pool longtext COMMENT 'var_pool' AFTER
alter table t_ds_process_instance add dry_run tinyint(4) DEFAULT '0' COMMENT 'dry run flag:0 normal, 1 dry run' AFTER var_pool; alter table t_ds_process_instance add dry_run tinyint(4) DEFAULT '0' COMMENT 'dry run flag:0 normal, 1 dry run' AFTER var_pool;
alter table t_ds_process_instance drop KEY `process_instance_index`; alter table t_ds_process_instance drop KEY `process_instance_index`;
alter table t_ds_process_instance add KEY `process_instance_index` (`process_definition_code`,`id`) USING BTREE; alter table t_ds_process_instance add KEY `process_instance_index` (`process_definition_code`,`id`) USING BTREE;
alter table t_ds_process_instance drop KEY `start_time_index`;
alter table t_ds_process_instance add KEY `start_time_index` (`start_time`,`end_time`) USING BTREE;
alter table t_ds_process_instance drop process_instance_json; alter table t_ds_process_instance drop process_instance_json;
alter table t_ds_process_instance drop locations; alter table t_ds_process_instance drop locations;
alter table t_ds_process_instance drop connects; alter table t_ds_process_instance drop connects;

3
dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_ddl.sql

@ -98,11 +98,12 @@ BEGIN
--- drop index --- drop index
EXECUTE 'DROP INDEX IF EXISTS "process_instance_index"'; EXECUTE 'DROP INDEX IF EXISTS "process_instance_index"';
EXECUTE 'DROP INDEX IF EXISTS "task_instance_index"'; EXECUTE 'DROP INDEX IF EXISTS "task_instance_index"';
EXECUTE 'DROP INDEX IF EXISTS "start_time_index"';
--- create index --- create index
EXECUTE 'CREATE INDEX IF NOT EXISTS priority_id_index ON ' || quote_ident(v_schema) ||'.t_ds_command USING Btree("process_instance_priority","id")'; EXECUTE 'CREATE INDEX IF NOT EXISTS priority_id_index ON ' || quote_ident(v_schema) ||'.t_ds_command USING Btree("process_instance_priority","id")';
EXECUTE 'CREATE INDEX IF NOT EXISTS process_instance_index ON ' || quote_ident(v_schema) ||'.t_ds_process_instance USING Btree("process_definition_code","id")'; EXECUTE 'CREATE INDEX IF NOT EXISTS process_instance_index ON ' || quote_ident(v_schema) ||'.t_ds_process_instance USING Btree("process_definition_code","id")';
EXECUTE 'CREATE INDEX IF NOT EXISTS start_time_index ON ' || quote_ident(v_schema) ||'.t_ds_process_instance USING Btree("start_time","end_time")';
---add comment ---add comment
EXECUTE 'comment on column ' || quote_ident(v_schema) ||'.t_ds_user.state is ''state 0:disable 1:enable'''; EXECUTE 'comment on column ' || quote_ident(v_schema) ||'.t_ds_user.state is ''state 0:disable 1:enable''';

Loading…
Cancel
Save