Browse Source

[2.0.1] change postgre sql for serial int (#7248)

* [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.

* [BUG][SQL] fix the process list page load slowly. (#7166)

* fix #7601 move ddl to 2.0.1

* fix #7601 move ddl to 2.0.1

* [2.0.1] remove unused foreign_key

* [2.0.1] add version in sql

* [2.0.1] change serial for postgre

Co-authored-by: GaoTianDuo <gaotianduo_yewu@cmss.chinamobile.com>
2.0.7-release
BaoLiang 3 years ago committed by GitHub
parent
commit
4e8507e6ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 49
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgre.sql
  2. 2
      dolphinscheduler-dao/src/main/resources/sql/soft_version

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

@ -191,7 +191,7 @@ CREATE INDEX IDX_QRTZ_FT_TG ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,TRIGGER_GROUP);
DROP TABLE IF EXISTS t_ds_access_token;
CREATE TABLE t_ds_access_token (
id int NOT NULL ,
id serial NOT NULL ,
user_id int DEFAULT NULL ,
token varchar(64) DEFAULT NULL ,
expire_time timestamp DEFAULT NULL ,
@ -206,7 +206,7 @@ CREATE TABLE t_ds_access_token (
DROP TABLE IF EXISTS t_ds_alert;
CREATE TABLE t_ds_alert (
id int NOT NULL ,
id serial NOT NULL ,
title varchar(64) DEFAULT NULL ,
content text ,
alert_status int DEFAULT '0' ,
@ -239,7 +239,7 @@ CREATE TABLE t_ds_alertgroup(
DROP TABLE IF EXISTS t_ds_command;
CREATE TABLE t_ds_command (
id int NOT NULL ,
id serial NOT NULL ,
command_type int DEFAULT NULL ,
process_definition_code bigint NOT NULL ,
command_param text ,
@ -268,7 +268,7 @@ create index priority_id_index on t_ds_command (process_instance_priority,id);
DROP TABLE IF EXISTS t_ds_datasource;
CREATE TABLE t_ds_datasource (
id int NOT NULL ,
id serial NOT NULL ,
name varchar(64) NOT NULL ,
note varchar(255) DEFAULT NULL ,
type int NOT NULL ,
@ -286,7 +286,7 @@ CREATE TABLE t_ds_datasource (
DROP TABLE IF EXISTS t_ds_error_command;
CREATE TABLE t_ds_error_command (
id int NOT NULL ,
id serial NOT NULL ,
command_type int DEFAULT NULL ,
process_definition_code bigint NOT NULL ,
command_param text ,
@ -317,7 +317,7 @@ CREATE TABLE t_ds_error_command (
DROP TABLE IF EXISTS t_ds_process_definition;
CREATE TABLE t_ds_process_definition (
id int NOT NULL ,
id serial NOT NULL ,
code bigint NOT NULL,
name varchar(255) DEFAULT NULL ,
version int NOT NULL ,
@ -366,7 +366,7 @@ CREATE TABLE t_ds_process_definition_log (
DROP TABLE IF EXISTS t_ds_task_definition;
CREATE TABLE t_ds_task_definition (
id int NOT NULL ,
id serial NOT NULL ,
code bigint NOT NULL,
name varchar(255) DEFAULT NULL ,
version int NOT NULL ,
@ -424,7 +424,7 @@ CREATE TABLE t_ds_task_definition_log (
DROP TABLE IF EXISTS t_ds_process_task_relation;
CREATE TABLE t_ds_process_task_relation (
id int NOT NULL ,
id serial NOT NULL ,
name varchar(255) DEFAULT NULL ,
project_code bigint DEFAULT NULL ,
process_definition_code bigint DEFAULT NULL ,
@ -466,7 +466,7 @@ CREATE TABLE t_ds_process_task_relation_log (
DROP TABLE IF EXISTS t_ds_process_instance;
CREATE TABLE t_ds_process_instance (
id int NOT NULL ,
id serial NOT NULL ,
name varchar(255) DEFAULT NULL ,
process_definition_code bigint DEFAULT NULL ,
process_definition_version int DEFAULT NULL ,
@ -513,7 +513,7 @@ create index start_time_index on t_ds_process_instance (start_time,end_time);
DROP TABLE IF EXISTS t_ds_project;
CREATE TABLE t_ds_project (
id int NOT NULL ,
id serial NOT NULL ,
name varchar(100) DEFAULT NULL ,
code bigint NOT NULL,
description varchar(200) DEFAULT NULL ,
@ -532,7 +532,7 @@ create index user_id_index on t_ds_project (user_id);
DROP TABLE IF EXISTS t_ds_queue;
CREATE TABLE t_ds_queue (
id int NOT NULL ,
id serial NOT NULL ,
queue_name varchar(64) DEFAULT NULL ,
queue varchar(64) DEFAULT NULL ,
create_time timestamp DEFAULT NULL ,
@ -547,7 +547,7 @@ CREATE TABLE t_ds_queue (
DROP TABLE IF EXISTS t_ds_relation_datasource_user;
CREATE TABLE t_ds_relation_datasource_user (
id int NOT NULL ,
id serial NOT NULL ,
user_id int NOT NULL ,
datasource_id int DEFAULT NULL ,
perm int DEFAULT '1' ,
@ -563,7 +563,7 @@ CREATE TABLE t_ds_relation_datasource_user (
DROP TABLE IF EXISTS t_ds_relation_process_instance;
CREATE TABLE t_ds_relation_process_instance (
id int NOT NULL ,
id serial NOT NULL ,
parent_process_instance_id int DEFAULT NULL ,
parent_task_instance_id int DEFAULT NULL ,
process_instance_id int DEFAULT NULL ,
@ -577,7 +577,7 @@ CREATE TABLE t_ds_relation_process_instance (
DROP TABLE IF EXISTS t_ds_relation_project_user;
CREATE TABLE t_ds_relation_project_user (
id int NOT NULL ,
id serial NOT NULL ,
user_id int NOT NULL ,
project_id int DEFAULT NULL ,
perm int DEFAULT '1' ,
@ -593,7 +593,7 @@ create index relation_project_user_id_index on t_ds_relation_project_user (user_
DROP TABLE IF EXISTS t_ds_relation_resources_user;
CREATE TABLE t_ds_relation_resources_user (
id int NOT NULL ,
id serial NOT NULL ,
user_id int NOT NULL ,
resources_id int DEFAULT NULL ,
perm int DEFAULT '1' ,
@ -608,7 +608,7 @@ CREATE TABLE t_ds_relation_resources_user (
DROP TABLE IF EXISTS t_ds_relation_udfs_user;
CREATE TABLE t_ds_relation_udfs_user (
id int NOT NULL ,
id serial NOT NULL ,
user_id int NOT NULL ,
udf_id int DEFAULT NULL ,
perm int DEFAULT '1' ,
@ -624,7 +624,7 @@ CREATE TABLE t_ds_relation_udfs_user (
DROP TABLE IF EXISTS t_ds_resources;
CREATE TABLE t_ds_resources (
id int NOT NULL ,
id serial NOT NULL ,
alias varchar(64) DEFAULT NULL ,
file_name varchar(64) DEFAULT NULL ,
description varchar(255) DEFAULT NULL ,
@ -647,7 +647,7 @@ CREATE TABLE t_ds_resources (
DROP TABLE IF EXISTS t_ds_schedules;
CREATE TABLE t_ds_schedules (
id int NOT NULL ,
id serial NOT NULL ,
process_definition_code bigint NOT NULL ,
start_time timestamp NOT NULL ,
end_time timestamp NOT NULL ,
@ -685,7 +685,7 @@ CREATE TABLE t_ds_session (
DROP TABLE IF EXISTS t_ds_task_instance;
CREATE TABLE t_ds_task_instance (
id int NOT NULL ,
id serial NOT NULL ,
name varchar(255) DEFAULT NULL ,
task_type varchar(50) DEFAULT NULL ,
task_code bigint NOT NULL,
@ -715,8 +715,7 @@ CREATE TABLE t_ds_task_instance (
delay_time int DEFAULT '0' ,
var_pool text ,
dry_run int DEFAULT '0' ,
PRIMARY KEY (id),
CONSTRAINT foreign_key_instance_id FOREIGN KEY(process_instance_id) REFERENCES t_ds_process_instance(id) ON DELETE CASCADE
PRIMARY KEY (id)
) ;
--
@ -725,7 +724,7 @@ CREATE TABLE t_ds_task_instance (
DROP TABLE IF EXISTS t_ds_tenant;
CREATE TABLE t_ds_tenant (
id int NOT NULL ,
id serial NOT NULL ,
tenant_code varchar(64) DEFAULT NULL ,
description varchar(255) DEFAULT NULL ,
queue_id int DEFAULT NULL ,
@ -740,7 +739,7 @@ CREATE TABLE t_ds_tenant (
DROP TABLE IF EXISTS t_ds_udfs;
CREATE TABLE t_ds_udfs (
id int NOT NULL ,
id serial NOT NULL ,
user_id int NOT NULL ,
func_name varchar(100) NOT NULL ,
class_name varchar(255) NOT NULL ,
@ -761,7 +760,7 @@ CREATE TABLE t_ds_udfs (
DROP TABLE IF EXISTS t_ds_user;
CREATE TABLE t_ds_user (
id int NOT NULL ,
id serial NOT NULL ,
user_name varchar(64) DEFAULT NULL ,
user_password varchar(64) DEFAULT NULL ,
user_type int DEFAULT NULL ,
@ -809,7 +808,7 @@ CREATE TABLE t_ds_worker_group (
DROP TABLE IF EXISTS t_ds_worker_server;
CREATE TABLE t_ds_worker_server (
id int NOT NULL ,
id serial NOT NULL ,
host varchar(45) DEFAULT NULL ,
port int DEFAULT NULL ,
zk_directory varchar(64) DEFAULT NULL ,

2
dolphinscheduler-dao/src/main/resources/sql/soft_version

@ -1 +1 @@
2.0.0
2.0.1
Loading…
Cancel
Save