From 8b67793a1ee8bf310fc1390036754d637f0785ba Mon Sep 17 00:00:00 2001 From: "emmanuel.duchastenier@bonitasoft.com" Date: Mon, 2 Dec 2024 14:19:42 +0100 Subject: [PATCH] fix(database): remove tenantId from indexes (#3248) to improve performance. Context: In 9.0.x, when removing the `:tenantId` filter on all Hibernate queries (because they were useless), we forgot to update the indexes. This commit fixes this. Note: Update Tool is also updated to reflect this change. See https://github.com/bonitasoft/bonita-migration-sp/pull/472 + add missing indexes on some RDBMS (mainly on Oracle) Relates to https://bonitasoft.atlassian.net/browse/RUNTIME-1911 --- .../main/resources/sql/h2/createTables.sql | 95 +++++++++--------- .../main/resources/sql/mysql/createTables.sql | 94 +++++++++--------- .../resources/sql/oracle/createTables.sql | 91 +++++++++--------- .../resources/sql/postgres/createTables.sql | 91 +++++++++--------- .../resources/sql/sqlserver/createTables.sql | 96 ++++++++++--------- 5 files changed, 235 insertions(+), 232 deletions(-) diff --git a/platform/platform-resources/src/main/resources/sql/h2/createTables.sql b/platform/platform-resources/src/main/resources/sql/h2/createTables.sql index 280bfadcdf4..9d47fe7f184 100644 --- a/platform/platform-resources/src/main/resources/sql/h2/createTables.sql +++ b/platform/platform-resources/src/main/resources/sql/h2/createTables.sql @@ -18,7 +18,7 @@ CREATE TABLE contract_data ( ); ALTER TABLE contract_data ADD CONSTRAINT pk_contract_data PRIMARY KEY (tenantid, id, scopeId); ALTER TABLE contract_data ADD CONSTRAINT uc_cd_scope_name UNIQUE (kind, scopeId, name, tenantid); -CREATE INDEX idx_cd_scope_name ON contract_data (kind, scopeId, name, tenantid); +CREATE INDEX idx_cd_kind_scope_name ON contract_data (kind, scopeId, name); CREATE TABLE arch_contract_data ( tenantid BIGINT NOT NULL, @@ -32,7 +32,7 @@ CREATE TABLE arch_contract_data ( ); ALTER TABLE arch_contract_data ADD CONSTRAINT pk_arch_contract_data PRIMARY KEY (tenantid, id, scopeId); ALTER TABLE arch_contract_data ADD CONSTRAINT uc_acd_scope_name UNIQUE (kind, scopeId, name, tenantid); -CREATE INDEX idx_acd_scope_name ON arch_contract_data (kind, scopeId, name, tenantid); +CREATE INDEX idx_acd_kind_scope_name ON arch_contract_data (kind, scopeId, name); CREATE TABLE actor ( tenantid BIGINT NOT NULL, @@ -90,8 +90,8 @@ CREATE TABLE arch_process_comment( PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx1_arch_process_comment on arch_process_comment (sourceobjectid, tenantid); -CREATE INDEX idx2_arch_process_comment on arch_process_comment (processInstanceId, archivedate, tenantid); +CREATE INDEX idx1_arch_process_comment on arch_process_comment (sourceobjectid); +CREATE INDEX idx2_arch_process_comment on arch_process_comment (processInstanceId, archivedate); CREATE TABLE process_comment ( tenantid BIGINT NOT NULL, id BIGINT NOT NULL, @@ -102,7 +102,7 @@ CREATE TABLE process_comment ( content VARCHAR(512) NOT NULL, PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx1_process_comment on process_comment (processInstanceId, tenantid); +CREATE INDEX idx1_process_comment on process_comment (processInstanceId); CREATE TABLE process_definition ( tenantid BIGINT NOT NULL, @@ -145,7 +145,7 @@ CREATE TABLE arch_document_mapping ( archiveDate BIGINT NOT NULL, PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_a_doc_mp_pr_id ON arch_document_mapping (processinstanceid, tenantid); +CREATE INDEX idx_a_doc_mp_pr_id ON arch_document_mapping (processinstanceid); CREATE TABLE document ( tenantid BIGINT NOT NULL, id BIGINT NOT NULL, @@ -192,9 +192,9 @@ CREATE TABLE arch_process_instance ( stringIndex5 VARCHAR(255), PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx1_arch_process_instance ON arch_process_instance (tenantId, sourceObjectId, rootProcessInstanceId, callerId); -CREATE INDEX idx2_arch_process_instance ON arch_process_instance (tenantId, processDefinitionId, archiveDate); -CREATE INDEX idx3_arch_process_instance ON arch_process_instance (tenantId, sourceObjectId, callerId, stateId); +CREATE INDEX idx1_arch_process_instance ON arch_process_instance (sourceObjectId, rootProcessInstanceId, callerId); +CREATE INDEX idx2_arch_process_instance ON arch_process_instance (processDefinitionId, archiveDate); +CREATE INDEX idx3_arch_process_instance ON arch_process_instance (sourceObjectId, callerId, stateId); CREATE TABLE arch_flownode_instance ( tenantid BIGINT NOT NULL, @@ -245,12 +245,12 @@ CREATE TABLE arch_flownode_instance ( interrupting BOOLEAN, PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_afi_kind_lg2_executedBy ON arch_flownode_instance(logicalGroup2, tenantId, kind, executedBy); -CREATE INDEX idx_afi_kind_lg3 ON arch_flownode_instance(tenantId, kind, logicalGroup3); -CREATE INDEX idx_afi_kind_lg4 ON arch_flownode_instance(tenantId, logicalGroup4); -CREATE INDEX idx_afi_sourceId_tenantid_kind ON arch_flownode_instance (sourceObjectId, tenantid, kind); -CREATE INDEX idx1_arch_flownode_instance ON arch_flownode_instance (tenantId, rootContainerId, parentContainerId); -CREATE INDEX idx_lg4_lg2 on arch_flownode_instance(tenantid, logicalGroup4, logicalGroup2); +CREATE INDEX idx_afi_kind_lg2_executedBy ON arch_flownode_instance(logicalGroup2, kind, executedBy); +CREATE INDEX idx_afi_kind_lg3 ON arch_flownode_instance(kind, logicalGroup3); +CREATE INDEX idx_afi_lg4 ON arch_flownode_instance(logicalGroup4); +CREATE INDEX idx_afi_sourceid_kind ON arch_flownode_instance (sourceObjectId, kind); +CREATE INDEX idx1_afi_root_parent ON arch_flownode_instance (rootContainerId, parentContainerId); +CREATE INDEX idx_lg4_lg2 on arch_flownode_instance(logicalGroup4, logicalGroup2); CREATE TABLE arch_connector_instance ( tenantid BIGINT NOT NULL, @@ -267,7 +267,7 @@ CREATE TABLE arch_connector_instance ( PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx1_arch_connector_instance ON arch_connector_instance (tenantId, containerId, containerType); +CREATE INDEX idx1_arch_connector_instance ON arch_connector_instance (containerId, containerType); CREATE TABLE process_instance ( id BIGINT NOT NULL, name VARCHAR(75) NOT NULL, @@ -348,9 +348,9 @@ CREATE TABLE flownode_instance ( ); CREATE INDEX idx_fni_rootcontid ON flownode_instance (rootContainerId); CREATE INDEX idx_fni_loggroup4 ON flownode_instance (logicalGroup4); -CREATE INDEX idx_fni_loggroup3_terminal ON flownode_instance(logicalgroup3, terminal, tenantid); -CREATE INDEX idx_fn_lg2_state_tenant_del ON flownode_instance (logicalGroup2, stateName, tenantid); -CREATE INDEX idx_fni_activity_instance_id_kind ON flownode_instance(activityInstanceId, kind, tenantid); +CREATE INDEX idx_fni_loggroup3_terminal ON flownode_instance(logicalgroup3, terminal); +CREATE INDEX idx_fn_lg2_state ON flownode_instance (logicalGroup2, stateName); +CREATE INDEX idx_fni_activity_instance_id_kind ON flownode_instance(activityInstanceId, kind); CREATE TABLE connector_instance ( tenantid BIGINT NOT NULL, @@ -367,7 +367,7 @@ CREATE TABLE connector_instance ( stackTrace CLOB, PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_ci_container_activation ON connector_instance (tenantid, containerId, containerType, activationEvent); +CREATE INDEX idx_ci_container_activation ON connector_instance (containerId, containerType, activationEvent); CREATE TABLE event_trigger_instance ( tenantid BIGINT NOT NULL, @@ -406,7 +406,7 @@ CREATE TABLE waiting_event ( correlation5 VARCHAR(128), PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_waiting_event ON waiting_event (progress, tenantid, kind, locked, active); +CREATE INDEX idx_waiting_event ON waiting_event (progress, kind, locked, active); CREATE INDEX idx_waiting_event_correl ON waiting_event (correlation1, correlation2, correlation3, correlation4, correlation5); CREATE TABLE message_instance ( @@ -438,7 +438,7 @@ CREATE TABLE pending_mapping ( userId BIGINT, PRIMARY KEY (tenantid, id) ); -CREATE UNIQUE INDEX idx_UQ_pending_mapping ON pending_mapping (tenantid, activityId, userId, actorId); +CREATE UNIQUE INDEX idx_UQ_pending_mapping ON pending_mapping (activityId, userId, actorId); CREATE TABLE ref_biz_data_inst ( tenantid BIGINT NOT NULL, @@ -451,10 +451,8 @@ CREATE TABLE ref_biz_data_inst ( data_classname VARCHAR(255) NOT NULL ); -CREATE INDEX idx_biz_data_inst1 ON ref_biz_data_inst (tenantid, proc_inst_id); - -CREATE INDEX idx_biz_data_inst2 ON ref_biz_data_inst (tenantid, fn_inst_id); - +CREATE INDEX idx_biz_data_inst2 ON ref_biz_data_inst (fn_inst_id); +CREATE INDEX idx_biz_data_inst3 ON ref_biz_data_inst (proc_inst_id); ALTER TABLE ref_biz_data_inst ADD CONSTRAINT pk_ref_biz_data_inst PRIMARY KEY (tenantid, id); ALTER TABLE ref_biz_data_inst ADD CONSTRAINT fk_ref_biz_data_proc FOREIGN KEY (proc_inst_id) REFERENCES process_instance(id) ON DELETE CASCADE; @@ -480,8 +478,8 @@ CREATE TABLE arch_ref_biz_data_inst ( data_id BIGINT, data_classname VARCHAR(255) NOT NULL ); -CREATE INDEX idx_arch_biz_data_inst1 ON arch_ref_biz_data_inst (tenantid, orig_proc_inst_id); -CREATE INDEX idx_arch_biz_data_inst2 ON arch_ref_biz_data_inst (tenantid, orig_fn_inst_id); +CREATE INDEX idx_arch_biz_data_inst1 ON arch_ref_biz_data_inst (orig_proc_inst_id); +CREATE INDEX idx_arch_biz_data_inst2 ON arch_ref_biz_data_inst (orig_fn_inst_id); ALTER TABLE arch_ref_biz_data_inst ADD CONSTRAINT pk_arch_ref_biz_data_inst PRIMARY KEY (tenantid, id); CREATE TABLE arch_multi_biz_data ( @@ -530,9 +528,9 @@ CREATE TABLE business_app ( ALTER TABLE business_app ADD CONSTRAINT pk_business_app PRIMARY KEY (tenantid, id); ALTER TABLE business_app ADD CONSTRAINT uk_app_token_version UNIQUE (tenantId, token, version); -CREATE INDEX idx_app_token ON business_app (token, tenantid); -CREATE INDEX idx_app_profile ON business_app (profileId, tenantid); -CREATE INDEX idx_app_homepage ON business_app (homePageId, tenantid); +CREATE INDEX idx_app_token ON business_app (token); +CREATE INDEX idx_app_profile ON business_app (profileId); +CREATE INDEX idx_app_homepage ON business_app (homePageId); CREATE TABLE business_app_page ( tenantId BIGINT NOT NULL, @@ -545,8 +543,8 @@ CREATE TABLE business_app_page ( ALTER TABLE business_app_page ADD CONSTRAINT pk_business_app_page PRIMARY KEY (tenantid, id); ALTER TABLE business_app_page ADD CONSTRAINT uk_app_page_appId_token UNIQUE (tenantId, applicationId, token); -CREATE INDEX idx_app_page_token ON business_app_page (applicationId, token, tenantid); -CREATE INDEX idx_app_page_pageId ON business_app_page (pageId, tenantid); +CREATE INDEX idx_app_page_token ON business_app_page (applicationId, token); +CREATE INDEX idx_app_page_pageId ON business_app_page (pageId); CREATE TABLE business_app_menu ( tenantId BIGINT NOT NULL, @@ -560,9 +558,9 @@ CREATE TABLE business_app_menu ( ALTER TABLE business_app_menu ADD CONSTRAINT pk_business_app_menu PRIMARY KEY (tenantid, id); -CREATE INDEX idx_app_menu_app ON business_app_menu (applicationId, tenantid); -CREATE INDEX idx_app_menu_page ON business_app_menu (applicationPageId, tenantid); -CREATE INDEX idx_app_menu_parent ON business_app_menu (parentId, tenantid); +CREATE INDEX idx_app_menu_app ON business_app_menu (applicationId); +CREATE INDEX idx_app_menu_page ON business_app_menu (applicationPageId); +CREATE INDEX idx_app_menu_parent ON business_app_menu (parentId); CREATE TABLE command ( tenantid BIGINT NOT NULL, @@ -599,8 +597,8 @@ CREATE TABLE arch_data_instance ( PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx1_arch_data_instance ON arch_data_instance (tenantId, containerId, containerType, archiveDate, name, sourceObjectId); -CREATE INDEX idx2_arch_data_instance ON arch_data_instance (sourceObjectId, containerId, archiveDate, id, tenantId); +CREATE INDEX idx1_arch_data_instance ON arch_data_instance (containerId, containerType, archiveDate, name, sourceObjectId); +CREATE INDEX idx2_arch_data_instance ON arch_data_instance (sourceObjectId, containerId, archiveDate, id); CREATE TABLE data_instance ( tenantId BIGINT NOT NULL, @@ -624,7 +622,7 @@ CREATE TABLE data_instance ( discriminant VARCHAR(50) NOT NULL, PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_datai_container ON data_instance (tenantId, containerId, containerType, name); +CREATE INDEX idx_datai_container ON data_instance (containerId, containerType, name); CREATE TABLE dependency ( tenantid BIGINT NOT NULL, @@ -693,7 +691,7 @@ CREATE TABLE group_ ( iconid BIGINT, PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_group_name ON group_ (tenantid, parentPath, name); +CREATE INDEX idx_group_name ON group_ (parentPath, name); CREATE TABLE role ( tenantid BIGINT NOT NULL, @@ -709,7 +707,7 @@ CREATE TABLE role ( PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_role_name ON role (tenantid, name); +CREATE INDEX idx_role_name ON role (name); CREATE TABLE user_ ( tenantid BIGINT NOT NULL, @@ -730,7 +728,7 @@ CREATE TABLE user_ ( PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_user_name ON user_ (tenantid, userName); +CREATE INDEX idx_user_name ON user_ (userName); CREATE TABLE user_login ( tenantid BIGINT NOT NULL, @@ -760,7 +758,7 @@ CREATE TABLE user_contactinfo ( PRIMARY KEY (tenantid, id) ); ALTER TABLE user_contactinfo ADD CONSTRAINT fk_contact_user FOREIGN KEY (tenantid, userId) REFERENCES user_ (tenantid, id) ON DELETE CASCADE; -CREATE INDEX idx_user_contactinfo ON user_contactinfo (userId, tenantid, personal); +CREATE INDEX idx_user_contactinfo ON user_contactinfo (userId, personal); CREATE TABLE custom_usr_inf_def ( @@ -772,7 +770,7 @@ CREATE TABLE custom_usr_inf_def ( PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_custom_usr_inf_def_name ON custom_usr_inf_def (tenantid, name); +CREATE INDEX idx_custom_usr_inf_def_name ON custom_usr_inf_def (name); CREATE TABLE custom_usr_inf_val ( id BIGINT NOT NULL, @@ -935,6 +933,7 @@ CREATE TABLE job_desc ( description VARCHAR(50), PRIMARY KEY (tenantid, id) ); +CREATE INDEX idx_job_desc_id ON job_desc(id); CREATE TABLE job_param ( tenantid BIGINT NOT NULL, @@ -945,7 +944,7 @@ CREATE TABLE job_param ( PRIMARY KEY (tenantid, id) ); ALTER TABLE job_param ADD CONSTRAINT fk_job_param_jobid FOREIGN KEY (tenantid, jobDescriptorId) REFERENCES job_desc(tenantid, id) ON DELETE CASCADE; -CREATE INDEX idx_job_param_tenant_jobid ON job_param (tenantid, jobDescriptorId); +CREATE INDEX idx_job_param_jobid ON job_param(jobDescriptorId); CREATE TABLE job_log ( @@ -958,8 +957,8 @@ CREATE TABLE job_log ( UNIQUE (tenantId, jobDescriptorId), PRIMARY KEY (tenantid, id) ); - ALTER TABLE job_log ADD CONSTRAINT fk_job_log_jobid FOREIGN KEY (tenantid, jobDescriptorId) REFERENCES job_desc(tenantid, id) ON DELETE CASCADE; +CREATE INDEX idx_job_log_jobdescid ON job_log(jobdescriptorid); CREATE TABLE form_mapping ( tenantId BIGINT NOT NULL, @@ -1009,7 +1008,7 @@ CREATE TABLE bar_resource ( UNIQUE (tenantId, process_id, name, type), PRIMARY KEY (tenantId, id) ); -CREATE INDEX idx_bar_resource ON bar_resource (tenantId, process_id, type, name); +CREATE INDEX idx_bar_resource ON bar_resource (process_id, type, name); CREATE TABLE temporary_content ( id BIGINT NOT NULL, @@ -1035,7 +1034,7 @@ CREATE TABLE tenant_resource ( CONSTRAINT UK_tenant_resource UNIQUE (tenantId, name, type), PRIMARY KEY (tenantId, id) ); -CREATE INDEX idx_tenant_resource ON tenant_resource (tenantId, type, name); +CREATE INDEX idx_tenant_resource ON tenant_resource (type, name); CREATE TABLE icon ( tenantId BIGINT NOT NULL, diff --git a/platform/platform-resources/src/main/resources/sql/mysql/createTables.sql b/platform/platform-resources/src/main/resources/sql/mysql/createTables.sql index 3ed0a471858..38ca80961f5 100644 --- a/platform/platform-resources/src/main/resources/sql/mysql/createTables.sql +++ b/platform/platform-resources/src/main/resources/sql/mysql/createTables.sql @@ -17,7 +17,7 @@ CREATE TABLE contract_data ( ) ENGINE = INNODB; ALTER TABLE contract_data ADD CONSTRAINT pk_contract_data PRIMARY KEY (tenantid, id, scopeId); ALTER TABLE contract_data ADD CONSTRAINT uc_cd_scope_name UNIQUE (kind, scopeId, name, tenantid); -CREATE INDEX idx_cd_scope_name ON contract_data (kind, scopeId, name, tenantid); +CREATE INDEX idx_cd_kind_scope_name ON contract_data (kind, scopeId, name); CREATE TABLE arch_contract_data ( tenantid BIGINT NOT NULL, @@ -31,7 +31,7 @@ CREATE TABLE arch_contract_data ( ) ENGINE = INNODB; ALTER TABLE arch_contract_data ADD CONSTRAINT pk_arch_contract_data PRIMARY KEY (tenantid, id, scopeId); ALTER TABLE arch_contract_data ADD CONSTRAINT uc_acd_scope_name UNIQUE (kind, scopeId, name, tenantid); -CREATE INDEX idx_acd_scope_name ON arch_contract_data (kind, scopeId, name, tenantid); +CREATE INDEX idx_acd_kind_scope_name ON arch_contract_data (kind, scopeId, name); CREATE TABLE actor ( tenantid BIGINT NOT NULL, @@ -89,8 +89,8 @@ CREATE TABLE arch_process_comment( sourceObjectId BIGINT NOT NULL, PRIMARY KEY (tenantid, id) ) ENGINE = INNODB; -CREATE INDEX idx1_arch_process_comment on arch_process_comment (sourceobjectid, tenantid); -CREATE INDEX idx2_arch_process_comment on arch_process_comment (processInstanceId, archivedate, tenantid); +CREATE INDEX idx1_arch_process_comment on arch_process_comment (sourceobjectid); +CREATE INDEX idx2_arch_process_comment on arch_process_comment (processInstanceId, archivedate); CREATE TABLE process_comment ( tenantid BIGINT NOT NULL, @@ -102,7 +102,7 @@ CREATE TABLE process_comment ( content VARCHAR(512) NOT NULL, PRIMARY KEY (tenantid, id) ) ENGINE = INNODB; -CREATE INDEX idx1_process_comment on process_comment (processInstanceId, tenantid); +CREATE INDEX idx1_process_comment on process_comment (processInstanceId); CREATE TABLE process_definition ( tenantid BIGINT NOT NULL, @@ -144,7 +144,7 @@ CREATE TABLE arch_document_mapping ( archiveDate BIGINT NOT NULL, PRIMARY KEY (tenantid, ID) ) ENGINE = INNODB; -CREATE INDEX idx_a_doc_mp_pr_id ON arch_document_mapping (processinstanceid, tenantid); +CREATE INDEX idx_a_doc_mp_pr_id ON arch_document_mapping (processinstanceid); CREATE TABLE document ( tenantid BIGINT NOT NULL, @@ -194,9 +194,9 @@ CREATE TABLE arch_process_instance ( stringIndex5 VARCHAR(255), PRIMARY KEY (tenantid, id) ) ENGINE = INNODB; -CREATE INDEX idx1_arch_process_instance ON arch_process_instance (tenantId, sourceObjectId, rootProcessInstanceId, callerId); -CREATE INDEX idx2_arch_process_instance ON arch_process_instance (tenantId, processDefinitionId, archiveDate); -CREATE INDEX idx3_arch_process_instance ON arch_process_instance (tenantId, sourceObjectId, callerId, stateId); +CREATE INDEX idx1_arch_process_instance ON arch_process_instance (sourceObjectId, rootProcessInstanceId, callerId); +CREATE INDEX idx2_arch_process_instance ON arch_process_instance (processDefinitionId, archiveDate); +CREATE INDEX idx3_arch_process_instance ON arch_process_instance (sourceObjectId, callerId, stateId); CREATE TABLE arch_flownode_instance ( tenantid BIGINT NOT NULL, @@ -247,12 +247,12 @@ CREATE TABLE arch_flownode_instance ( interrupting BOOLEAN, PRIMARY KEY (tenantid, id) ) ENGINE = INNODB; -CREATE INDEX idx_afi_kind_lg2_executedBy ON arch_flownode_instance(logicalGroup2, tenantId, kind, executedBy); -CREATE INDEX idx_afi_kind_lg3 ON arch_flownode_instance(tenantId, kind, logicalGroup3); -CREATE INDEX idx_afi_kind_lg4 ON arch_flownode_instance(tenantId, logicalGroup4); -CREATE INDEX idx_afi_sourceId_tenantid_kind ON arch_flownode_instance (sourceObjectId, tenantid, kind); -CREATE INDEX idx1_arch_flownode_instance ON arch_flownode_instance (tenantId, rootContainerId, parentContainerId); -CREATE INDEX idx_lg4_lg2 on arch_flownode_instance(tenantid, logicalGroup4, logicalGroup2); +CREATE INDEX idx_afi_kind_lg2_executedBy ON arch_flownode_instance(logicalGroup2, kind, executedBy); +CREATE INDEX idx_afi_kind_lg3 ON arch_flownode_instance(kind, logicalGroup3); +CREATE INDEX idx_afi_lg4 ON arch_flownode_instance(logicalGroup4); +CREATE INDEX idx_afi_sourceid_kind ON arch_flownode_instance (sourceObjectId, kind); +CREATE INDEX idx1_afi_root_parent ON arch_flownode_instance (rootContainerId, parentContainerId); +CREATE INDEX idx_lg4_lg2 on arch_flownode_instance(logicalGroup4, logicalGroup2); CREATE TABLE arch_connector_instance ( tenantid BIGINT NOT NULL, @@ -269,7 +269,7 @@ CREATE TABLE arch_connector_instance ( PRIMARY KEY (tenantid, id) ) ENGINE = INNODB; -CREATE INDEX idx1_arch_connector_instance ON arch_connector_instance (tenantId, containerId, containerType); +CREATE INDEX idx1_arch_connector_instance ON arch_connector_instance (containerId, containerType); CREATE TABLE process_instance ( id BIGINT NOT NULL, name VARCHAR(75) NOT NULL, @@ -350,9 +350,9 @@ CREATE TABLE flownode_instance ( ) ENGINE = INNODB; CREATE INDEX idx_fni_rootcontid ON flownode_instance (rootContainerId); CREATE INDEX idx_fni_loggroup4 ON flownode_instance (logicalGroup4); -CREATE INDEX idx_fni_loggroup3_terminal ON flownode_instance(logicalgroup3, terminal, tenantid); -CREATE INDEX idx_fn_lg2_state_tenant_del ON flownode_instance (logicalGroup2, stateName, tenantid); -CREATE INDEX idx_fni_activity_instance_id_kind ON flownode_instance(activityInstanceId, kind, tenantid); +CREATE INDEX idx_fni_loggroup3_terminal ON flownode_instance(logicalgroup3, terminal); +CREATE INDEX idx_fn_lg2_state ON flownode_instance (logicalGroup2, stateName); +CREATE INDEX idx_fni_activity_instance_id_kind ON flownode_instance(activityInstanceId, kind); CREATE TABLE connector_instance ( tenantid BIGINT NOT NULL, @@ -369,7 +369,7 @@ CREATE TABLE connector_instance ( stackTrace TEXT, PRIMARY KEY (tenantid, id) ) ENGINE = INNODB; -CREATE INDEX idx_ci_container_activation ON connector_instance (tenantid, containerId, containerType, activationEvent); +CREATE INDEX idx_ci_container_activation ON connector_instance (containerId, containerType, activationEvent); CREATE TABLE event_trigger_instance ( tenantid BIGINT NOT NULL, @@ -408,7 +408,7 @@ CREATE TABLE waiting_event ( correlation5 VARCHAR(128), PRIMARY KEY (tenantid, id) ) ENGINE = INNODB; -CREATE INDEX idx_waiting_event ON waiting_event (progress, tenantid, kind, locked, active); +CREATE INDEX idx_waiting_event ON waiting_event (progress, kind, locked, active); CREATE INDEX idx_waiting_event_correl ON waiting_event (correlation1, correlation2, correlation3, correlation4, correlation5); CREATE TABLE message_instance ( @@ -440,7 +440,7 @@ CREATE TABLE pending_mapping ( userId BIGINT, PRIMARY KEY (tenantid, id) ) ENGINE = INNODB; -CREATE UNIQUE INDEX idx_UQ_pending_mapping ON pending_mapping (tenantid, activityId, userId, actorId); +CREATE UNIQUE INDEX idx_UQ_pending_mapping ON pending_mapping (activityId, userId, actorId); CREATE TABLE ref_biz_data_inst ( tenantid BIGINT NOT NULL, @@ -453,8 +453,7 @@ CREATE TABLE ref_biz_data_inst ( data_classname VARCHAR(255) NOT NULL ) ENGINE = INNODB; -CREATE INDEX idx_biz_data_inst1 ON ref_biz_data_inst (tenantid, proc_inst_id); -CREATE INDEX idx_biz_data_inst2 ON ref_biz_data_inst (tenantid, fn_inst_id); +CREATE INDEX idx_biz_data_inst2 ON ref_biz_data_inst (fn_inst_id); CREATE INDEX idx_biz_data_inst3 ON ref_biz_data_inst (proc_inst_id); ALTER TABLE ref_biz_data_inst ADD CONSTRAINT pk_ref_biz_data_inst PRIMARY KEY (tenantid, id); ALTER TABLE ref_biz_data_inst ADD CONSTRAINT fk_ref_biz_data_proc FOREIGN KEY (proc_inst_id) REFERENCES process_instance(id) ON DELETE CASCADE; @@ -480,8 +479,8 @@ CREATE TABLE arch_ref_biz_data_inst ( data_id BIGINT, data_classname VARCHAR(255) NOT NULL ); -CREATE INDEX idx_arch_biz_data_inst1 ON arch_ref_biz_data_inst (tenantid, orig_proc_inst_id); -CREATE INDEX idx_arch_biz_data_inst2 ON arch_ref_biz_data_inst (tenantid, orig_fn_inst_id); +CREATE INDEX idx_arch_biz_data_inst1 ON arch_ref_biz_data_inst (orig_proc_inst_id); +CREATE INDEX idx_arch_biz_data_inst2 ON arch_ref_biz_data_inst (orig_fn_inst_id); ALTER TABLE arch_ref_biz_data_inst ADD CONSTRAINT pk_arch_ref_biz_data_inst PRIMARY KEY (tenantid, id); CREATE TABLE arch_multi_biz_data ( @@ -530,9 +529,9 @@ CREATE TABLE business_app ( ALTER TABLE business_app ADD CONSTRAINT pk_business_app PRIMARY KEY (tenantid, id); ALTER TABLE business_app ADD CONSTRAINT uk_app_token_version UNIQUE (tenantId, token, version); -CREATE INDEX idx_app_token ON business_app (token, tenantid); -CREATE INDEX idx_app_profile ON business_app (profileId, tenantid); -CREATE INDEX idx_app_homepage ON business_app (homePageId, tenantid); +CREATE INDEX idx_app_token ON business_app (token); +CREATE INDEX idx_app_profile ON business_app (profileId); +CREATE INDEX idx_app_homepage ON business_app (homePageId); CREATE TABLE business_app_page ( tenantId BIGINT NOT NULL, @@ -545,8 +544,8 @@ CREATE TABLE business_app_page ( ALTER TABLE business_app_page ADD CONSTRAINT pk_business_app_page PRIMARY KEY (tenantid, id); ALTER TABLE business_app_page ADD CONSTRAINT uk_app_page_appId_token UNIQUE (tenantId, applicationId, token); -CREATE INDEX idx_app_page_token ON business_app_page (applicationId, token, tenantid); -CREATE INDEX idx_app_page_pageId ON business_app_page (pageId, tenantid); +CREATE INDEX idx_app_page_token ON business_app_page (applicationId, token); +CREATE INDEX idx_app_page_pageId ON business_app_page (pageId); CREATE TABLE business_app_menu ( tenantId BIGINT NOT NULL, @@ -560,9 +559,9 @@ CREATE TABLE business_app_menu ( ALTER TABLE business_app_menu ADD CONSTRAINT pk_business_app_menu PRIMARY KEY (tenantid, id); -CREATE INDEX idx_app_menu_app ON business_app_menu (applicationId, tenantid); -CREATE INDEX idx_app_menu_page ON business_app_menu (applicationPageId, tenantid); -CREATE INDEX idx_app_menu_parent ON business_app_menu (parentId, tenantid); +CREATE INDEX idx_app_menu_app ON business_app_menu (applicationId); +CREATE INDEX idx_app_menu_page ON business_app_menu (applicationPageId); +CREATE INDEX idx_app_menu_parent ON business_app_menu (parentId); CREATE TABLE command ( tenantid BIGINT NOT NULL, @@ -599,8 +598,8 @@ CREATE TABLE arch_data_instance ( PRIMARY KEY (tenantid, id) ) ENGINE = INNODB; -CREATE INDEX idx1_arch_data_instance ON arch_data_instance (tenantId, containerId, containerType, archiveDate, name, sourceObjectId); -CREATE INDEX idx2_arch_data_instance ON arch_data_instance (sourceObjectId, containerId, archiveDate, id, tenantId); +CREATE INDEX idx1_arch_data_instance ON arch_data_instance (containerId, containerType, archiveDate, name, sourceObjectId); +CREATE INDEX idx2_arch_data_instance ON arch_data_instance (sourceObjectId, containerId, archiveDate, id); CREATE TABLE data_instance ( tenantId BIGINT NOT NULL, @@ -624,7 +623,7 @@ CREATE TABLE data_instance ( discriminant VARCHAR(50) NOT NULL, PRIMARY KEY (tenantid, id) ) ENGINE = INNODB; -CREATE INDEX idx_datai_container ON data_instance (tenantId, containerId, containerType, name); +CREATE INDEX idx_datai_container ON data_instance (containerId, containerType, name); CREATE TABLE dependency ( tenantid BIGINT NOT NULL, @@ -694,7 +693,7 @@ CREATE TABLE group_ ( iconid BIGINT, PRIMARY KEY (tenantid, id) ) ENGINE = INNODB; -CREATE INDEX idx_group_name ON group_ (tenantid, parentPath, name); +CREATE INDEX idx_group_name ON group_ (parentPath, name); CREATE TABLE role ( tenantid BIGINT NOT NULL, @@ -710,7 +709,7 @@ CREATE TABLE role ( PRIMARY KEY (tenantid, id) ) ENGINE = INNODB; -CREATE INDEX idx_role_name ON role (tenantid, name); +CREATE INDEX idx_role_name ON role (name); CREATE TABLE user_ ( tenantid BIGINT NOT NULL, @@ -731,7 +730,7 @@ CREATE TABLE user_ ( PRIMARY KEY (tenantid, id) ) ENGINE = INNODB; -CREATE INDEX idx_user_name ON user_ (tenantid, userName); +CREATE INDEX idx_user_name ON user_ (userName); CREATE TABLE user_login ( tenantid BIGINT NOT NULL, @@ -761,7 +760,7 @@ CREATE TABLE user_contactinfo ( PRIMARY KEY (tenantid, id) ) ENGINE = INNODB; ALTER TABLE user_contactinfo ADD CONSTRAINT fk_contact_user FOREIGN KEY (tenantid, userId) REFERENCES user_ (tenantid, id) ON DELETE CASCADE; -CREATE INDEX idx_user_contactinfo ON user_contactinfo (userId, tenantid, personal); +CREATE INDEX idx_user_contactinfo ON user_contactinfo (userId, personal); CREATE TABLE custom_usr_inf_def ( @@ -773,7 +772,7 @@ CREATE TABLE custom_usr_inf_def ( PRIMARY KEY (tenantid, id) ) ENGINE = INNODB; -CREATE INDEX idx_custom_usr_inf_def_name ON custom_usr_inf_def (tenantid, name); +CREATE INDEX idx_custom_usr_inf_def_name ON custom_usr_inf_def (name); CREATE TABLE custom_usr_inf_val ( id BIGINT NOT NULL, @@ -939,7 +938,7 @@ CREATE TABLE job_desc ( description VARCHAR(50), PRIMARY KEY (tenantid, id) ) ENGINE = INNODB; -CREATE INDEX fk_job_desc_Id_idx ON job_desc(id ASC, tenantid ASC); +CREATE INDEX idx_job_desc_id ON job_desc(id ASC); CREATE TABLE job_param ( tenantid BIGINT NOT NULL, @@ -949,9 +948,8 @@ CREATE TABLE job_param ( value_ MEDIUMBLOB NOT NULL, PRIMARY KEY (tenantid, id) ) ENGINE = INNODB; -CREATE INDEX fk_job_param_jobId_idx ON job_param(jobDescriptorId ASC, tenantid ASC); +CREATE INDEX idx_job_param_jobid ON job_param(jobDescriptorId ASC); ALTER TABLE job_param ADD CONSTRAINT fk_job_param_jobid FOREIGN KEY (tenantid, jobDescriptorId) REFERENCES job_desc(tenantid, id) ON DELETE CASCADE; -CREATE INDEX idx_job_param_tenant_jobid ON job_param (tenantid, jobDescriptorId); CREATE TABLE job_log ( tenantid BIGINT NOT NULL, @@ -963,7 +961,7 @@ CREATE TABLE job_log ( UNIQUE (tenantId, jobDescriptorId), PRIMARY KEY (tenantid, id) ) ENGINE = INNODB; -CREATE INDEX fk_job_log_jobId_idx ON job_log(jobDescriptorId ASC, tenantid ASC); +CREATE INDEX idx_job_log_jobdescid ON job_log(jobDescriptorId ASC); ALTER TABLE job_log ADD CONSTRAINT fk_job_log_jobid FOREIGN KEY (tenantid, jobDescriptorId) REFERENCES job_desc(tenantid, id) ON DELETE CASCADE; @@ -1016,7 +1014,7 @@ CREATE TABLE bar_resource ( UNIQUE (tenantId, process_id, name, type), PRIMARY KEY (tenantId, id) ) ENGINE = INNODB; -CREATE INDEX idx_bar_resource ON bar_resource (tenantId, process_id, type, name); +CREATE INDEX idx_bar_resource ON bar_resource (process_id, type, name); CREATE TABLE temporary_content ( id BIGINT NOT NULL, @@ -1042,7 +1040,7 @@ CREATE TABLE tenant_resource ( CONSTRAINT UK_tenant_resource UNIQUE (tenantId, name, type), PRIMARY KEY (tenantId, id) ) ENGINE = INNODB; -CREATE INDEX idx_tenant_resource ON tenant_resource (tenantId, type, name); +CREATE INDEX idx_tenant_resource ON tenant_resource (type, name); CREATE TABLE icon ( tenantId BIGINT NOT NULL, diff --git a/platform/platform-resources/src/main/resources/sql/oracle/createTables.sql b/platform/platform-resources/src/main/resources/sql/oracle/createTables.sql index 32e81c4a1ba..28987a157a7 100644 --- a/platform/platform-resources/src/main/resources/sql/oracle/createTables.sql +++ b/platform/platform-resources/src/main/resources/sql/oracle/createTables.sql @@ -17,6 +17,7 @@ CREATE TABLE contract_data ( ); ALTER TABLE contract_data ADD CONSTRAINT pk_contract_data PRIMARY KEY (tenantid, id, scopeId); ALTER TABLE contract_data ADD CONSTRAINT uc_cd_scope_name UNIQUE (kind, scopeId, name, tenantid); +CREATE INDEX idx_cd_kind_scope_name ON contract_data(kind, scopeId, name); CREATE TABLE arch_contract_data ( tenantid NUMBER(19, 0) NOT NULL, @@ -30,6 +31,7 @@ CREATE TABLE arch_contract_data ( ); ALTER TABLE arch_contract_data ADD CONSTRAINT pk_arch_contract_data PRIMARY KEY (tenantid, id, scopeId); ALTER TABLE arch_contract_data ADD CONSTRAINT uc_acd_scope_name UNIQUE (kind, scopeId, name, tenantid); +CREATE INDEX idx_acd_kind_scope_name ON arch_contract_data(kind, scopeId, name); CREATE TABLE actor ( tenantid NUMBER(19, 0) NOT NULL, @@ -88,8 +90,8 @@ CREATE TABLE arch_process_comment( PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx1_arch_process_comment on arch_process_comment (sourceobjectid, tenantid); -CREATE INDEX idx2_arch_process_comment on arch_process_comment (processInstanceId, archivedate, tenantid); +CREATE INDEX idx1_arch_process_comment on arch_process_comment (sourceobjectid); +CREATE INDEX idx2_arch_process_comment on arch_process_comment (processInstanceId, archivedate); CREATE TABLE process_comment ( tenantid NUMBER(19, 0) NOT NULL, id NUMBER(19, 0) NOT NULL, @@ -100,7 +102,7 @@ CREATE TABLE process_comment ( content VARCHAR2(512 CHAR) NOT NULL, PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx1_process_comment on process_comment (processInstanceId, tenantid); +CREATE INDEX idx1_process_comment on process_comment (processInstanceId); CREATE TABLE process_definition ( tenantId NUMBER(19, 0) NOT NULL, @@ -142,7 +144,7 @@ CREATE TABLE arch_document_mapping ( archiveDate NUMBER(19, 0) NOT NULL, PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_a_doc_mp_pr_id ON arch_document_mapping (processinstanceid, tenantid); +CREATE INDEX idx_a_doc_mp_pr_id ON arch_document_mapping (processinstanceid); CREATE TABLE document ( tenantid NUMBER(19, 0) NOT NULL, id NUMBER(19, 0) NOT NULL, @@ -189,9 +191,9 @@ CREATE TABLE arch_process_instance ( stringIndex5 VARCHAR2(255 CHAR), PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx1_arch_process_instance ON arch_process_instance (tenantId, sourceObjectId, rootProcessInstanceId, callerId); -CREATE INDEX idx2_arch_process_instance ON arch_process_instance (tenantId, processDefinitionId, archiveDate); -CREATE INDEX idx3_arch_process_instance ON arch_process_instance (tenantId, sourceObjectId, callerId, stateId); +CREATE INDEX idx1_arch_process_instance ON arch_process_instance (sourceObjectId, rootProcessInstanceId, callerId); +CREATE INDEX idx2_arch_process_instance ON arch_process_instance (processDefinitionId, archiveDate); +CREATE INDEX idx3_arch_process_instance ON arch_process_instance (sourceObjectId, callerId, stateId); CREATE TABLE arch_flownode_instance ( tenantid NUMBER(19, 0) NOT NULL, @@ -242,12 +244,12 @@ CREATE TABLE arch_flownode_instance ( interrupting NUMBER(1), PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_afi_kind_lg2_executedBy ON arch_flownode_instance(logicalGroup2, tenantId, kind, executedBy); -CREATE INDEX idx_afi_kind_lg3 ON arch_flownode_instance(tenantId, kind, logicalGroup3); -CREATE INDEX idx_afi_kind_lg4 ON arch_flownode_instance(tenantId, logicalGroup4); -CREATE INDEX idx_afi_sourceId_tenantid_kind ON arch_flownode_instance (sourceObjectId, tenantid, kind); -CREATE INDEX idx1_arch_flownode_instance ON arch_flownode_instance (tenantId, rootContainerId, parentContainerId); -CREATE INDEX idx_lg4_lg2 on arch_flownode_instance(tenantid, logicalGroup4, logicalGroup2); +CREATE INDEX idx_afi_kind_lg2_executedBy ON arch_flownode_instance(logicalGroup2, kind, executedBy); +CREATE INDEX idx_afi_kind_lg3 ON arch_flownode_instance(kind, logicalGroup3); +CREATE INDEX idx_afi_lg4 ON arch_flownode_instance(logicalGroup4); +CREATE INDEX idx_afi_sourceid_kind ON arch_flownode_instance (sourceObjectId, kind); +CREATE INDEX idx1_afi_root_parent ON arch_flownode_instance (rootContainerId, parentContainerId); +CREATE INDEX idx_lg4_lg2 on arch_flownode_instance(logicalGroup4, logicalGroup2); CREATE TABLE arch_connector_instance ( tenantid NUMBER(19, 0) NOT NULL, @@ -264,7 +266,7 @@ CREATE TABLE arch_connector_instance ( PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx1_arch_connector_instance ON arch_connector_instance (tenantId, containerId, containerType); +CREATE INDEX idx1_arch_connector_instance ON arch_connector_instance (containerId, containerType); CREATE TABLE process_instance ( id NUMBER(19, 0) NOT NULL, name VARCHAR2(75 CHAR) NOT NULL, @@ -345,9 +347,9 @@ CREATE TABLE flownode_instance ( ); CREATE INDEX idx_fni_rootcontid ON flownode_instance (rootContainerId); CREATE INDEX idx_fni_loggroup4 ON flownode_instance (logicalGroup4); -CREATE INDEX idx_fni_loggroup3_terminal ON flownode_instance(logicalgroup3, terminal, tenantid); -CREATE INDEX idx_fn_lg2_state_tenant_del ON flownode_instance (logicalGroup2, stateName, tenantid); -CREATE INDEX idx_fni_activity_instance_id_kind ON flownode_instance(activityInstanceId, kind, tenantid); +CREATE INDEX idx_fni_loggroup3_terminal ON flownode_instance(logicalgroup3, terminal); +CREATE INDEX idx_fn_lg2_state ON flownode_instance (logicalGroup2, stateName); +CREATE INDEX idx_fni_activity_instance_id_kind ON flownode_instance(activityInstanceId, kind); CREATE TABLE connector_instance ( tenantid NUMBER(19, 0) NOT NULL, @@ -364,7 +366,7 @@ CREATE TABLE connector_instance ( stackTrace CLOB, PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_ci_container_activation ON connector_instance (tenantid, containerId, containerType, activationEvent); +CREATE INDEX idx_ci_container_activation ON connector_instance (containerId, containerType, activationEvent); CREATE TABLE event_trigger_instance ( tenantid NUMBER(19, 0) NOT NULL, @@ -403,7 +405,7 @@ CREATE TABLE waiting_event ( correlation5 VARCHAR2(128 CHAR), PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_waiting_event ON waiting_event (progress, tenantid, kind, locked, active); +CREATE INDEX idx_waiting_event ON waiting_event (progress, kind, locked, active); CREATE INDEX idx_waiting_event_correl ON waiting_event (correlation1, correlation2, correlation3, correlation4, correlation5); CREATE TABLE message_instance ( @@ -435,7 +437,7 @@ CREATE TABLE pending_mapping ( userId NUMBER(19, 0), PRIMARY KEY (tenantid, id) ); -CREATE UNIQUE INDEX idx_UQ_pending_mapping ON pending_mapping (tenantid, activityId, userId, actorId); +CREATE UNIQUE INDEX idx_UQ_pending_mapping ON pending_mapping (activityId, userId, actorId); CREATE TABLE ref_biz_data_inst ( @@ -449,8 +451,7 @@ CREATE TABLE ref_biz_data_inst ( data_classname VARCHAR2(255 CHAR) NOT NULL ); -CREATE INDEX idx_biz_data_inst1 ON ref_biz_data_inst (tenantid, proc_inst_id); -CREATE INDEX idx_biz_data_inst2 ON ref_biz_data_inst (tenantid, fn_inst_id); +CREATE INDEX idx_biz_data_inst2 ON ref_biz_data_inst (fn_inst_id); CREATE INDEX idx_biz_data_inst3 ON ref_biz_data_inst (proc_inst_id); ALTER TABLE ref_biz_data_inst ADD CONSTRAINT pk_ref_biz_data_inst PRIMARY KEY (tenantid, id); ALTER TABLE ref_biz_data_inst ADD CONSTRAINT fk_ref_biz_data_proc FOREIGN KEY (proc_inst_id) REFERENCES process_instance(id) ON DELETE CASCADE; @@ -476,8 +477,8 @@ CREATE TABLE arch_ref_biz_data_inst ( data_id NUMBER(19, 0), data_classname VARCHAR2(255 CHAR) NOT NULL ); -CREATE INDEX idx_arch_biz_data_inst1 ON arch_ref_biz_data_inst (tenantid, orig_proc_inst_id); -CREATE INDEX idx_arch_biz_data_inst2 ON arch_ref_biz_data_inst (tenantid, orig_fn_inst_id); +CREATE INDEX idx_arch_biz_data_inst1 ON arch_ref_biz_data_inst (orig_proc_inst_id); +CREATE INDEX idx_arch_biz_data_inst2 ON arch_ref_biz_data_inst (orig_fn_inst_id); ALTER TABLE arch_ref_biz_data_inst ADD CONSTRAINT pk_arch_ref_biz_data_inst PRIMARY KEY (tenantid, id); CREATE TABLE arch_multi_biz_data ( @@ -526,9 +527,9 @@ CREATE TABLE business_app ( ALTER TABLE business_app ADD CONSTRAINT pk_business_app PRIMARY KEY (tenantid, id); ALTER TABLE business_app ADD CONSTRAINT UK_Business_app UNIQUE (tenantId, token, version); -CREATE INDEX idx_app_token ON business_app (token, tenantid); -CREATE INDEX idx_app_profile ON business_app (profileId, tenantid); -CREATE INDEX idx_app_homepage ON business_app (homePageId, tenantid); +CREATE INDEX idx_app_token ON business_app (token); +CREATE INDEX idx_app_profile ON business_app (profileId); +CREATE INDEX idx_app_homepage ON business_app (homePageId); CREATE TABLE business_app_page ( tenantId NUMBER(19, 0) NOT NULL, @@ -541,8 +542,8 @@ CREATE TABLE business_app_page ( ALTER TABLE business_app_page ADD CONSTRAINT pk_business_app_page PRIMARY KEY (tenantid, id); ALTER TABLE business_app_page ADD CONSTRAINT UK_Business_app_page UNIQUE (tenantId, applicationId, token); -CREATE INDEX idx_app_page_token ON business_app_page (applicationId, token, tenantid); -CREATE INDEX idx_app_page_pageId ON business_app_page (pageId, tenantid); +CREATE INDEX idx_app_page_token ON business_app_page (applicationId, token); +CREATE INDEX idx_app_page_pageId ON business_app_page (pageId); CREATE TABLE business_app_menu ( tenantId NUMBER(19, 0) NOT NULL, @@ -556,9 +557,9 @@ CREATE TABLE business_app_menu ( ALTER TABLE business_app_menu ADD CONSTRAINT pk_business_app_menu PRIMARY KEY (tenantid, id); -CREATE INDEX idx_app_menu_app ON business_app_menu (applicationId, tenantid); -CREATE INDEX idx_app_menu_page ON business_app_menu (applicationPageId, tenantid); -CREATE INDEX idx_app_menu_parent ON business_app_menu (parentId, tenantid); +CREATE INDEX idx_app_menu_app ON business_app_menu (applicationId); +CREATE INDEX idx_app_menu_page ON business_app_menu (applicationPageId); +CREATE INDEX idx_app_menu_parent ON business_app_menu (parentId); CREATE TABLE command ( tenantid NUMBER(19, 0) NOT NULL, @@ -595,8 +596,8 @@ CREATE TABLE arch_data_instance ( PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx1_arch_data_instance ON arch_data_instance (tenantId, containerId, containerType, archiveDate, name, sourceObjectId); -CREATE INDEX idx2_arch_data_instance ON arch_data_instance (sourceObjectId, containerId, archiveDate, id, tenantId); +CREATE INDEX idx1_arch_data_instance ON arch_data_instance (containerId, containerType, archiveDate, name, sourceObjectId); +CREATE INDEX idx2_arch_data_instance ON arch_data_instance (sourceObjectId, containerId, archiveDate, id); CREATE TABLE data_instance ( tenantId NUMBER(19, 0) NOT NULL, @@ -620,7 +621,7 @@ CREATE TABLE data_instance ( discriminant VARCHAR2(50 CHAR) NOT NULL, PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_datai_container ON data_instance (tenantId, containerId, containerType, name); +CREATE INDEX idx_datai_container ON data_instance (containerId, containerType, name); CREATE TABLE dependency ( tenantid NUMBER(19, 0) NOT NULL, @@ -687,7 +688,7 @@ CREATE TABLE group_ ( iconid NUMBER(19, 0), PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_group_name ON group_ (tenantid, parentPath, name); +CREATE INDEX idx_group_name ON group_ (parentPath, name); CREATE TABLE role ( tenantid NUMBER(19, 0) NOT NULL, @@ -702,7 +703,7 @@ CREATE TABLE role ( CONSTRAINT UK_Role UNIQUE (tenantId, name), PRIMARY KEY (tenantid, id) ); - +CREATE INDEX idx_role_name ON role(name); CREATE TABLE user_ ( tenantid NUMBER(19, 0) NOT NULL, @@ -722,7 +723,7 @@ CREATE TABLE user_ ( CONSTRAINT UK_User UNIQUE (tenantid, userName), PRIMARY KEY (tenantid, id) ); - +CREATE INDEX idx_user_name ON user_(userName); CREATE TABLE user_login ( tenantid NUMBER(19, 0) NOT NULL, @@ -752,7 +753,7 @@ CREATE TABLE user_contactinfo ( PRIMARY KEY (tenantid, id) ); ALTER TABLE user_contactinfo ADD CONSTRAINT fk_contact_user FOREIGN KEY (tenantid, userId) REFERENCES user_ (tenantid, id) ON DELETE CASCADE; - +CREATE INDEX idx_user_contactinfo ON user_contactinfo(userId, personal); CREATE TABLE custom_usr_inf_def ( tenantid NUMBER(19, 0) NOT NULL, @@ -762,7 +763,7 @@ CREATE TABLE custom_usr_inf_def ( CONSTRAINT UK_Custom_Usr_Inf_Def UNIQUE (tenantId, name), PRIMARY KEY (tenantid, id) ); - +CREATE INDEX idx_custom_usr_inf_def_name ON custom_usr_inf_def(name); CREATE TABLE custom_usr_inf_val ( id NUMBER(19, 0) NOT NULL, @@ -928,6 +929,7 @@ CREATE TABLE job_desc ( description VARCHAR2(50 CHAR), PRIMARY KEY (tenantId, id) ); +CREATE INDEX idx_job_desc_id ON job_desc(id); CREATE TABLE job_param ( tenantId NUMBER(19, 0) NOT NULL, @@ -937,7 +939,7 @@ CREATE TABLE job_param ( value_ BLOB NOT NULL, PRIMARY KEY (tenantId, id) ); -CREATE INDEX idx_job_param_tenant_jobid ON job_param (tenantid, jobDescriptorId); +CREATE INDEX idx_job_param_jobid ON job_param(jobDescriptorId); CREATE TABLE job_log ( tenantId NUMBER(19, 0) NOT NULL, @@ -949,9 +951,9 @@ CREATE TABLE job_log ( UNIQUE (tenantId, jobDescriptorId), PRIMARY KEY (tenantId, id) ); - ALTER TABLE job_param ADD CONSTRAINT fk_job_param_jobid FOREIGN KEY (tenantid, jobDescriptorId) REFERENCES job_desc(tenantid, id) ON DELETE CASCADE; ALTER TABLE job_log ADD CONSTRAINT fk_job_log_jobid FOREIGN KEY (tenantid, jobDescriptorId) REFERENCES job_desc(tenantid, id) ON DELETE CASCADE; +CREATE INDEX idx_job_log_jobdescid ON job_log(jobdescriptorid); CREATE TABLE form_mapping ( tenantId NUMBER(19, 0) NOT NULL, @@ -1002,7 +1004,7 @@ CREATE TABLE bar_resource ( UNIQUE (tenantId, process_id, name, type), PRIMARY KEY (tenantId, id) ); -CREATE INDEX idx_bar_resource ON bar_resource (tenantId, process_id, type, name); +CREATE INDEX idx_bar_resource ON bar_resource (process_id, type, name); CREATE TABLE temporary_content ( id NUMBER(19, 0) NOT NULL, @@ -1014,6 +1016,7 @@ CREATE TABLE temporary_content ( UNIQUE (key_), PRIMARY KEY (id) ); +-- no need to create an index on key_ since it is unique (already indexed on Oracle) CREATE TABLE tenant_resource ( tenantId NUMBER(19, 0) NOT NULL, @@ -1027,7 +1030,7 @@ CREATE TABLE tenant_resource ( CONSTRAINT UK_tenant_resource UNIQUE (tenantId, name, type), PRIMARY KEY (tenantId, id) ); -CREATE INDEX idx_tenant_resource ON tenant_resource (tenantId, type, name); +CREATE INDEX idx_tenant_resource ON tenant_resource (type, name); CREATE TABLE icon ( tenantId NUMBER(19, 0) NOT NULL, diff --git a/platform/platform-resources/src/main/resources/sql/postgres/createTables.sql b/platform/platform-resources/src/main/resources/sql/postgres/createTables.sql index 260f0c199da..de667c1c034 100644 --- a/platform/platform-resources/src/main/resources/sql/postgres/createTables.sql +++ b/platform/platform-resources/src/main/resources/sql/postgres/createTables.sql @@ -20,7 +20,7 @@ ALTER TABLE contract_data ADD CONSTRAINT pk_contract_data PRIMARY KEY (tenantid, ALTER TABLE contract_data ADD CONSTRAINT uc_cd_scope_name UNIQUE (kind, scopeId, name, tenantid); -CREATE INDEX idx_cd_scope_name ON contract_data (kind, scopeId, name, tenantid); +CREATE INDEX idx_cd_kind_scope_name ON contract_data (kind, scopeId, name); CREATE TABLE arch_contract_data ( tenantid INT8 NOT NULL, @@ -34,7 +34,7 @@ CREATE TABLE arch_contract_data ( ); ALTER TABLE arch_contract_data ADD CONSTRAINT pk_arch_contract_data PRIMARY KEY (tenantid, id, scopeId); ALTER TABLE arch_contract_data ADD CONSTRAINT uc_acd_scope_name UNIQUE (kind, scopeId, name, tenantid); -CREATE INDEX idx_acd_scope_name ON arch_contract_data (kind, scopeId, name, tenantid); +CREATE INDEX idx_acd_kind_scope_name ON arch_contract_data (kind, scopeId, name); CREATE TABLE actor ( tenantid INT8 NOT NULL, @@ -93,8 +93,8 @@ CREATE TABLE arch_process_comment( PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx1_arch_process_comment on arch_process_comment (sourceobjectid, tenantid); -CREATE INDEX idx2_arch_process_comment on arch_process_comment (processInstanceId, archivedate, tenantid); +CREATE INDEX idx1_arch_process_comment on arch_process_comment (sourceobjectid); +CREATE INDEX idx2_arch_process_comment on arch_process_comment (processInstanceId, archivedate); CREATE TABLE process_comment ( tenantid INT8 NOT NULL, id INT8 NOT NULL, @@ -105,7 +105,7 @@ CREATE TABLE process_comment ( content VARCHAR(512) NOT NULL, PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx1_process_comment on process_comment (processInstanceId, tenantid); +CREATE INDEX idx1_process_comment on process_comment (processInstanceId); CREATE TABLE process_definition ( tenantid INT8 NOT NULL, @@ -147,7 +147,7 @@ CREATE TABLE arch_document_mapping ( archiveDate INT8 NOT NULL, PRIMARY KEY (tenantid, ID) ); -CREATE INDEX idx_a_doc_mp_pr_id ON arch_document_mapping (processinstanceid, tenantid); +CREATE INDEX idx_a_doc_mp_pr_id ON arch_document_mapping (processinstanceid); CREATE TABLE document ( tenantid INT8 NOT NULL, id INT8 NOT NULL, @@ -194,9 +194,9 @@ CREATE TABLE arch_process_instance ( stringIndex5 VARCHAR(255), PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx1_arch_process_instance ON arch_process_instance (tenantId, sourceObjectId, rootProcessInstanceId, callerId); -CREATE INDEX idx2_arch_process_instance ON arch_process_instance (tenantId, processDefinitionId, archiveDate); -CREATE INDEX idx3_arch_process_instance ON arch_process_instance (tenantId, sourceObjectId, callerId, stateId); +CREATE INDEX idx1_arch_process_instance ON arch_process_instance (sourceObjectId, rootProcessInstanceId, callerId); +CREATE INDEX idx2_arch_process_instance ON arch_process_instance (processDefinitionId, archiveDate); +CREATE INDEX idx3_arch_process_instance ON arch_process_instance (sourceObjectId, callerId, stateId); CREATE TABLE arch_flownode_instance ( tenantid INT8 NOT NULL, @@ -247,12 +247,12 @@ CREATE TABLE arch_flownode_instance ( interrupting BOOLEAN, PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_afi_kind_lg2_executedBy ON arch_flownode_instance(logicalGroup2, tenantId, kind, executedBy); -CREATE INDEX idx_afi_kind_lg3 ON arch_flownode_instance(tenantId, kind, logicalGroup3); -CREATE INDEX idx_afi_kind_lg4 ON arch_flownode_instance(tenantId, logicalGroup4); -CREATE INDEX idx_afi_sourceId_tenantid_kind ON arch_flownode_instance (sourceObjectId, tenantid, kind); -CREATE INDEX idx1_arch_flownode_instance ON arch_flownode_instance (tenantId, rootContainerId, parentContainerId); -CREATE INDEX idx_lg4_lg2 on arch_flownode_instance(tenantid, logicalGroup4, logicalGroup2); +CREATE INDEX idx_afi_kind_lg2_executedBy ON arch_flownode_instance(logicalGroup2, kind, executedBy); +CREATE INDEX idx_afi_kind_lg3 ON arch_flownode_instance(kind, logicalGroup3); +CREATE INDEX idx_afi_lg4 ON arch_flownode_instance(logicalGroup4); +CREATE INDEX idx_afi_sourceid_kind ON arch_flownode_instance (sourceObjectId, kind); +CREATE INDEX idx1_afi_root_parent ON arch_flownode_instance (rootContainerId, parentContainerId); +CREATE INDEX idx_lg4_lg2 on arch_flownode_instance(logicalGroup4, logicalGroup2); CREATE TABLE arch_connector_instance ( tenantid INT8 NOT NULL, @@ -269,7 +269,7 @@ CREATE TABLE arch_connector_instance ( PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx1_arch_connector_instance ON arch_connector_instance (tenantId, containerId, containerType); +CREATE INDEX idx1_arch_connector_instance ON arch_connector_instance (containerId, containerType); CREATE TABLE process_instance ( id INT8 NOT NULL, name VARCHAR(75) NOT NULL, @@ -350,9 +350,9 @@ CREATE TABLE flownode_instance ( ); CREATE INDEX idx_fni_rootcontid ON flownode_instance (rootContainerId); CREATE INDEX idx_fni_loggroup4 ON flownode_instance (logicalGroup4); -CREATE INDEX idx_fni_loggroup3_terminal ON flownode_instance(logicalgroup3, terminal, tenantid); -CREATE INDEX idx_fn_lg2_state_tenant_del ON flownode_instance (logicalGroup2, stateName, tenantid); -CREATE INDEX idx_fni_activity_instance_id_kind ON flownode_instance(activityInstanceId, kind, tenantid); +CREATE INDEX idx_fni_loggroup3_terminal ON flownode_instance(logicalgroup3, terminal); +CREATE INDEX idx_fn_lg2_state ON flownode_instance (logicalGroup2, stateName); +CREATE INDEX idx_fni_activity_instance_id_kind ON flownode_instance(activityInstanceId, kind); CREATE TABLE connector_instance ( tenantid INT8 NOT NULL, @@ -369,7 +369,7 @@ CREATE TABLE connector_instance ( stackTrace TEXT, PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_ci_container_activation ON connector_instance (tenantid, containerId, containerType, activationEvent); +CREATE INDEX idx_ci_container_activation ON connector_instance (containerId, containerType, activationEvent); CREATE TABLE event_trigger_instance ( tenantid INT8 NOT NULL, @@ -408,7 +408,7 @@ CREATE TABLE waiting_event ( correlation5 VARCHAR(128), PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_waiting_event ON waiting_event (progress, tenantid, kind, locked, active); +CREATE INDEX idx_waiting_event ON waiting_event (progress, kind, locked, active); CREATE INDEX idx_waiting_event_correl ON waiting_event (correlation1, correlation2, correlation3, correlation4, correlation5); CREATE TABLE message_instance ( @@ -440,7 +440,7 @@ CREATE TABLE pending_mapping ( userId INT8, PRIMARY KEY (tenantid, id) ); -CREATE UNIQUE INDEX idx_UQ_pending_mapping ON pending_mapping (tenantid, activityId, userId, actorId); +CREATE UNIQUE INDEX idx_UQ_pending_mapping ON pending_mapping (activityId, userId, actorId); CREATE TABLE ref_biz_data_inst ( tenantid INT8 NOT NULL, @@ -453,8 +453,7 @@ CREATE TABLE ref_biz_data_inst ( data_classname VARCHAR(255) NOT NULL ); -CREATE INDEX idx_biz_data_inst1 ON ref_biz_data_inst (tenantid, proc_inst_id); -CREATE INDEX idx_biz_data_inst2 ON ref_biz_data_inst (tenantid, fn_inst_id); +CREATE INDEX idx_biz_data_inst2 ON ref_biz_data_inst (fn_inst_id); CREATE INDEX idx_biz_data_inst3 ON ref_biz_data_inst (proc_inst_id); ALTER TABLE ref_biz_data_inst ADD CONSTRAINT pk_ref_biz_data_inst PRIMARY KEY (tenantid, id); ALTER TABLE ref_biz_data_inst ADD CONSTRAINT fk_ref_biz_data_proc FOREIGN KEY (proc_inst_id) REFERENCES process_instance(id) ON DELETE CASCADE; @@ -480,8 +479,8 @@ CREATE TABLE arch_ref_biz_data_inst ( data_id BIGINT, data_classname VARCHAR(255) NOT NULL ); -CREATE INDEX idx_arch_biz_data_inst1 ON arch_ref_biz_data_inst (tenantid, orig_proc_inst_id); -CREATE INDEX idx_arch_biz_data_inst2 ON arch_ref_biz_data_inst (tenantid, orig_fn_inst_id); +CREATE INDEX idx_arch_biz_data_inst1 ON arch_ref_biz_data_inst (orig_proc_inst_id); +CREATE INDEX idx_arch_biz_data_inst2 ON arch_ref_biz_data_inst (orig_fn_inst_id); ALTER TABLE arch_ref_biz_data_inst ADD CONSTRAINT pk_arch_ref_biz_data_inst PRIMARY KEY (tenantid, id); CREATE TABLE arch_multi_biz_data ( @@ -530,9 +529,9 @@ CREATE TABLE business_app ( ALTER TABLE business_app ADD CONSTRAINT pk_business_app PRIMARY KEY (tenantid, id); ALTER TABLE business_app ADD CONSTRAINT uk_app_token_version UNIQUE (tenantId, token, version); -CREATE INDEX idx_app_token ON business_app (token, tenantid); -CREATE INDEX idx_app_profile ON business_app (profileId, tenantid); -CREATE INDEX idx_app_homepage ON business_app (homePageId, tenantid); +CREATE INDEX idx_app_token ON business_app (token); +CREATE INDEX idx_app_profile ON business_app (profileId); +CREATE INDEX idx_app_homepage ON business_app (homePageId); CREATE TABLE business_app_page ( tenantId INT8 NOT NULL, @@ -545,8 +544,8 @@ CREATE TABLE business_app_page ( ALTER TABLE business_app_page ADD CONSTRAINT pk_business_app_page PRIMARY KEY (tenantid, id); ALTER TABLE business_app_page ADD CONSTRAINT uk_app_page_appId_token UNIQUE (tenantId, applicationId, token); -CREATE INDEX idx_app_page_token ON business_app_page (applicationId, token, tenantid); -CREATE INDEX idx_app_page_pageId ON business_app_page (pageId, tenantid); +CREATE INDEX idx_app_page_token ON business_app_page (applicationId, token); +CREATE INDEX idx_app_page_pageId ON business_app_page (pageId); CREATE TABLE business_app_menu ( tenantId INT8 NOT NULL, @@ -560,9 +559,9 @@ CREATE TABLE business_app_menu ( ALTER TABLE business_app_menu ADD CONSTRAINT pk_business_app_menu PRIMARY KEY (tenantid, id); -CREATE INDEX idx_app_menu_app ON business_app_menu (applicationId, tenantid); -CREATE INDEX idx_app_menu_page ON business_app_menu (applicationPageId, tenantid); -CREATE INDEX idx_app_menu_parent ON business_app_menu (parentId, tenantid); +CREATE INDEX idx_app_menu_app ON business_app_menu (applicationId); +CREATE INDEX idx_app_menu_page ON business_app_menu (applicationPageId); +CREATE INDEX idx_app_menu_parent ON business_app_menu (parentId); CREATE TABLE command ( tenantid INT8 NOT NULL, @@ -599,8 +598,8 @@ CREATE TABLE arch_data_instance ( PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx1_arch_data_instance ON arch_data_instance (tenantId, containerId, containerType, archiveDate, name, sourceObjectId); -CREATE INDEX idx2_arch_data_instance ON arch_data_instance (sourceObjectId, containerId, archiveDate, id, tenantId); +CREATE INDEX idx1_arch_data_instance ON arch_data_instance (containerId, containerType, archiveDate, name, sourceObjectId); +CREATE INDEX idx2_arch_data_instance ON arch_data_instance (sourceObjectId, containerId, archiveDate, id); CREATE TABLE data_instance ( tenantId INT8 NOT NULL, @@ -624,7 +623,7 @@ CREATE TABLE data_instance ( discriminant VARCHAR(50) NOT NULL, PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_datai_container ON data_instance (tenantId, containerId, containerType, name); +CREATE INDEX idx_datai_container ON data_instance (containerId, containerType, name); CREATE TABLE dependency ( tenantid INT8 NOT NULL, @@ -693,7 +692,7 @@ CREATE TABLE group_ ( iconid INT8, PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_group_name ON group_ (tenantid, parentPath, name); +CREATE INDEX idx_group_name ON group_ (parentPath, name); CREATE TABLE role ( tenantid INT8 NOT NULL, @@ -709,7 +708,7 @@ CREATE TABLE role ( PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_role_name ON role (tenantid, name); +CREATE INDEX idx_role_name ON role (name); CREATE TABLE user_ ( tenantid INT8 NOT NULL, @@ -730,7 +729,7 @@ CREATE TABLE user_ ( PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_user_name ON user_ (tenantid, userName); +CREATE INDEX idx_user_name ON user_ (userName); CREATE TABLE user_login ( tenantid INT8 NOT NULL, @@ -760,7 +759,7 @@ CREATE TABLE user_contactinfo ( PRIMARY KEY (tenantid, id) ); ALTER TABLE user_contactinfo ADD CONSTRAINT fk_contact_user FOREIGN KEY (tenantid, userId) REFERENCES user_ (tenantid, id) ON DELETE CASCADE; -CREATE INDEX idx_user_contactinfo ON user_contactinfo (userId, tenantid, personal); +CREATE INDEX idx_user_contactinfo ON user_contactinfo (userId, personal); CREATE TABLE custom_usr_inf_def ( @@ -772,7 +771,7 @@ CREATE TABLE custom_usr_inf_def ( PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_custom_usr_inf_def_name ON custom_usr_inf_def (tenantid, name); +CREATE INDEX idx_custom_usr_inf_def_name ON custom_usr_inf_def (name); CREATE TABLE custom_usr_inf_val ( id INT8 NOT NULL, @@ -937,6 +936,7 @@ CREATE TABLE job_desc ( description VARCHAR(50), PRIMARY KEY (tenantid, id) ); +CREATE INDEX idx_job_desc_id ON job_desc(id); CREATE TABLE job_param ( tenantid INT8 NOT NULL, @@ -946,7 +946,7 @@ CREATE TABLE job_param ( value_ BYTEA NOT NULL, PRIMARY KEY (tenantid, id) ); -CREATE INDEX idx_job_param_tenant_jobid ON job_param (tenantid, jobDescriptorId); +CREATE INDEX idx_job_param_jobid ON job_param(jobDescriptorId); CREATE TABLE job_log ( tenantid INT8 NOT NULL, @@ -960,6 +960,7 @@ CREATE TABLE job_log ( ALTER TABLE job_param ADD CONSTRAINT fk_job_param_jobid FOREIGN KEY (tenantid, jobDescriptorId) REFERENCES job_desc(tenantid, id) ON DELETE CASCADE; ALTER TABLE job_log ADD CONSTRAINT fk_job_log_jobid FOREIGN KEY (tenantid, jobDescriptorId) REFERENCES job_desc(tenantid, id) ON DELETE CASCADE; +CREATE INDEX idx_job_log_jobdescid ON job_log(jobdescriptorid); CREATE TABLE form_mapping ( tenantId INT8 NOT NULL, @@ -1008,7 +1009,7 @@ CREATE TABLE bar_resource ( UNIQUE (tenantId, process_id, name, type), PRIMARY KEY (tenantId, id) ); -CREATE INDEX idx_bar_resource ON bar_resource (tenantId, process_id, type, name); +CREATE INDEX idx_bar_resource ON bar_resource (process_id, type, name); CREATE TABLE temporary_content ( id INT8 NOT NULL, @@ -1034,7 +1035,7 @@ CREATE TABLE tenant_resource ( CONSTRAINT UK_tenant_resource UNIQUE (tenantId, name, type), PRIMARY KEY (tenantId, id) ); -CREATE INDEX idx_tenant_resource ON tenant_resource (tenantId, type, name); +CREATE INDEX idx_tenant_resource ON tenant_resource (type, name); CREATE TABLE icon ( tenantId INT8 NOT NULL, diff --git a/platform/platform-resources/src/main/resources/sql/sqlserver/createTables.sql b/platform/platform-resources/src/main/resources/sql/sqlserver/createTables.sql index 360fdaafdcc..37b29cd55bc 100644 --- a/platform/platform-resources/src/main/resources/sql/sqlserver/createTables.sql +++ b/platform/platform-resources/src/main/resources/sql/sqlserver/createTables.sql @@ -23,7 +23,7 @@ ALTER TABLE contract_data ADD CONSTRAINT pk_contract_data PRIMARY KEY (tenantid, GO ALTER TABLE contract_data ADD CONSTRAINT uc_cd_scope_name UNIQUE (kind, scopeId, name, tenantid) GO -CREATE INDEX idx_cd_scope_name ON contract_data (kind, scopeId, name, tenantid) +CREATE INDEX idx_cd_kind_scope_name ON contract_data (kind, scopeId, name) GO CREATE TABLE arch_contract_data ( @@ -41,7 +41,7 @@ ALTER TABLE arch_contract_data ADD CONSTRAINT pk_arch_contract_data PRIMARY KEY GO ALTER TABLE arch_contract_data ADD CONSTRAINT uc_acd_scope_name UNIQUE (kind, scopeId, name, tenantid) GO -CREATE INDEX idx_acd_scope_name ON arch_contract_data (kind, scopeId, name, tenantid) +CREATE INDEX idx_acd_kind_scope_name ON arch_contract_data (kind, scopeId, name) GO CREATE TABLE actor ( @@ -106,9 +106,9 @@ CREATE TABLE arch_process_comment( ) GO -CREATE INDEX idx1_arch_process_comment on arch_process_comment (sourceobjectid, tenantid) +CREATE INDEX idx1_arch_process_comment on arch_process_comment (sourceobjectid) GO -CREATE INDEX idx2_arch_process_comment on arch_process_comment (processInstanceId, archivedate, tenantid) +CREATE INDEX idx2_arch_process_comment on arch_process_comment (processInstanceId, archivedate) GO CREATE TABLE process_comment ( tenantid NUMERIC(19, 0) NOT NULL, @@ -121,7 +121,7 @@ CREATE TABLE process_comment ( PRIMARY KEY (tenantid, id) ) GO -CREATE INDEX idx1_process_comment on process_comment (processInstanceId, tenantid) +CREATE INDEX idx1_process_comment on process_comment (processInstanceId) GO CREATE TABLE process_definition ( tenantid NUMERIC(19, 0) NOT NULL, @@ -166,7 +166,7 @@ CREATE TABLE arch_document_mapping ( PRIMARY KEY (tenantid, ID) ) GO -CREATE INDEX idx_a_doc_mp_pr_id ON arch_document_mapping (processinstanceid, tenantid) +CREATE INDEX idx_a_doc_mp_pr_id ON arch_document_mapping (processinstanceid) GO CREATE TABLE document ( tenantid NUMERIC(19, 0) NOT NULL, @@ -217,11 +217,11 @@ CREATE TABLE arch_process_instance ( PRIMARY KEY (tenantid, id) ) GO -CREATE INDEX idx1_arch_process_instance ON arch_process_instance (tenantId, sourceObjectId, rootProcessInstanceId, callerId) +CREATE INDEX idx1_arch_process_instance ON arch_process_instance (sourceObjectId, rootProcessInstanceId, callerId) GO -CREATE INDEX idx2_arch_process_instance ON arch_process_instance (tenantId, processDefinitionId, archiveDate) +CREATE INDEX idx2_arch_process_instance ON arch_process_instance (processDefinitionId, archiveDate) GO -CREATE INDEX idx3_arch_process_instance ON arch_process_instance (tenantId, sourceObjectId, callerId, stateId) +CREATE INDEX idx3_arch_process_instance ON arch_process_instance (sourceObjectId, callerId, stateId) GO CREATE TABLE arch_flownode_instance ( @@ -274,17 +274,17 @@ CREATE TABLE arch_flownode_instance ( PRIMARY KEY (tenantid, id) ) GO -CREATE INDEX idx_afi_kind_lg2_executedBy ON arch_flownode_instance(logicalGroup2, tenantId, kind, executedBy) +CREATE INDEX idx_afi_kind_lg2_executedBy ON arch_flownode_instance(logicalGroup2, kind, executedBy) GO -CREATE INDEX idx_afi_kind_lg3 ON arch_flownode_instance(tenantId, kind, logicalGroup3) +CREATE INDEX idx_afi_kind_lg3 ON arch_flownode_instance(kind, logicalGroup3) GO -CREATE INDEX idx_afi_kind_lg4 ON arch_flownode_instance(tenantId, logicalGroup4) +CREATE INDEX idx_afi_lg4 ON arch_flownode_instance(logicalGroup4) GO -CREATE INDEX idx_afi_sourceId_tenantid_kind ON arch_flownode_instance (sourceObjectId, tenantid, kind) +CREATE INDEX idx_afi_sourceid_kind ON arch_flownode_instance (sourceObjectId, kind) GO -CREATE INDEX idx1_arch_flownode_instance ON arch_flownode_instance (tenantId, rootContainerId, parentContainerId) +CREATE INDEX idx1_afi_root_parent ON arch_flownode_instance (rootContainerId, parentContainerId) GO -CREATE INDEX idx_lg4_lg2 on arch_flownode_instance(tenantid, logicalGroup4, logicalGroup2); +CREATE INDEX idx_lg4_lg2 on arch_flownode_instance(logicalGroup4, logicalGroup2); GO CREATE TABLE arch_connector_instance ( @@ -303,7 +303,7 @@ CREATE TABLE arch_connector_instance ( ) GO -CREATE INDEX idx1_arch_connector_instance ON arch_connector_instance (tenantId, containerId, containerType) +CREATE INDEX idx1_arch_connector_instance ON arch_connector_instance (containerId, containerType) GO CREATE TABLE process_instance ( id NUMERIC(19, 0) NOT NULL, @@ -390,11 +390,11 @@ CREATE INDEX idx_fni_rootcontid ON flownode_instance (rootContainerId) GO CREATE INDEX idx_fni_loggroup4 ON flownode_instance (logicalGroup4) GO -CREATE INDEX idx_fni_loggroup3_terminal ON flownode_instance(logicalgroup3, terminal, tenantid) +CREATE INDEX idx_fni_loggroup3_terminal ON flownode_instance(logicalgroup3, terminal) GO -CREATE INDEX idx_fn_lg2_state_tenant_del ON flownode_instance (logicalGroup2, stateName, tenantid) +CREATE INDEX idx_fn_lg2_state ON flownode_instance (logicalGroup2, stateName) GO -CREATE INDEX idx_fni_activity_instance_id_kind ON flownode_instance(activityInstanceId, kind, tenantid) +CREATE INDEX idx_fni_activity_instance_id_kind ON flownode_instance(activityInstanceId, kind) GO CREATE TABLE connector_instance ( @@ -413,7 +413,7 @@ CREATE TABLE connector_instance ( PRIMARY KEY (tenantid, id) ) GO -CREATE INDEX idx_ci_container_activation ON connector_instance (tenantid, containerId, containerType, activationEvent) +CREATE INDEX idx_ci_container_activation ON connector_instance (containerId, containerType, activationEvent) GO CREATE TABLE event_trigger_instance ( @@ -455,7 +455,7 @@ CREATE TABLE waiting_event ( PRIMARY KEY (tenantid, id) ) GO -CREATE INDEX idx_waiting_event ON waiting_event (progress, tenantid, kind, locked, active) +CREATE INDEX idx_waiting_event ON waiting_event (progress, kind, locked, active) GO CREATE INDEX idx_waiting_event_correl ON waiting_event (correlation1, correlation2, correlation3, correlation4, correlation5) GO @@ -493,7 +493,7 @@ CREATE TABLE pending_mapping ( PRIMARY KEY (tenantid, id) ) GO -CREATE UNIQUE INDEX idx_UQ_pending_mapping ON pending_mapping (tenantid, activityId, userId, actorId) +CREATE UNIQUE INDEX idx_UQ_pending_mapping ON pending_mapping (activityId, userId, actorId) GO CREATE TABLE ref_biz_data_inst ( @@ -508,9 +508,7 @@ CREATE TABLE ref_biz_data_inst ( ) GO -CREATE INDEX idx_biz_data_inst1 ON ref_biz_data_inst (tenantid, proc_inst_id) -GO -CREATE INDEX idx_biz_data_inst2 ON ref_biz_data_inst (tenantid, fn_inst_id) +CREATE INDEX idx_biz_data_inst2 ON ref_biz_data_inst (fn_inst_id) GO CREATE INDEX idx_biz_data_inst3 ON ref_biz_data_inst (proc_inst_id) GO @@ -544,9 +542,9 @@ CREATE TABLE arch_ref_biz_data_inst ( data_classname NVARCHAR(255) NOT NULL ) GO -CREATE INDEX idx_arch_biz_data_inst1 ON arch_ref_biz_data_inst (tenantid, orig_proc_inst_id) +CREATE INDEX idx_arch_biz_data_inst1 ON arch_ref_biz_data_inst (orig_proc_inst_id) GO -CREATE INDEX idx_arch_biz_data_inst2 ON arch_ref_biz_data_inst (tenantid, orig_fn_inst_id) +CREATE INDEX idx_arch_biz_data_inst2 ON arch_ref_biz_data_inst (orig_fn_inst_id) GO ALTER TABLE arch_ref_biz_data_inst ADD CONSTRAINT pk_arch_ref_biz_data_inst PRIMARY KEY (tenantid, id) GO @@ -604,11 +602,11 @@ GO ALTER TABLE business_app ADD CONSTRAINT uk_app_token_version UNIQUE (tenantId, token, version) GO -CREATE INDEX idx_app_token ON business_app (token, tenantid) +CREATE INDEX idx_app_token ON business_app (token) GO -CREATE INDEX idx_app_profile ON business_app (profileId, tenantid) +CREATE INDEX idx_app_profile ON business_app (profileId) GO -CREATE INDEX idx_app_homepage ON business_app (homePageId, tenantid) +CREATE INDEX idx_app_homepage ON business_app (homePageId) GO CREATE TABLE business_app_page ( @@ -625,9 +623,9 @@ GO ALTER TABLE business_app_page ADD CONSTRAINT uk_app_page_appId_token UNIQUE (tenantId, applicationId, token) GO -CREATE INDEX idx_app_page_token ON business_app_page (applicationId, token, tenantid) +CREATE INDEX idx_app_page_token ON business_app_page (applicationId, token) GO -CREATE INDEX idx_app_page_pageId ON business_app_page (pageId, tenantid) +CREATE INDEX idx_app_page_pageId ON business_app_page (pageId) GO CREATE TABLE business_app_menu ( @@ -644,11 +642,11 @@ GO ALTER TABLE business_app_menu ADD CONSTRAINT pk_business_app_menu PRIMARY KEY (tenantid, id) GO -CREATE INDEX idx_app_menu_app ON business_app_menu (applicationId, tenantid) +CREATE INDEX idx_app_menu_app ON business_app_menu (applicationId) GO -CREATE INDEX idx_app_menu_page ON business_app_menu (applicationPageId, tenantid) +CREATE INDEX idx_app_menu_page ON business_app_menu (applicationPageId) GO -CREATE INDEX idx_app_menu_parent ON business_app_menu (parentId, tenantid) +CREATE INDEX idx_app_menu_parent ON business_app_menu (parentId) GO CREATE TABLE command ( @@ -688,9 +686,9 @@ CREATE TABLE arch_data_instance ( ) GO -CREATE INDEX idx1_arch_data_instance ON arch_data_instance (tenantId, containerId, containerType, archiveDate, name, sourceObjectId) +CREATE INDEX idx1_arch_data_instance ON arch_data_instance (containerId, containerType, archiveDate, name, sourceObjectId) GO -CREATE INDEX idx2_arch_data_instance ON arch_data_instance (sourceObjectId, containerId, archiveDate, id, tenantId) +CREATE INDEX idx2_arch_data_instance ON arch_data_instance (sourceObjectId, containerId, archiveDate, id) GO CREATE TABLE data_instance ( @@ -716,7 +714,7 @@ CREATE TABLE data_instance ( PRIMARY KEY (tenantid, id) ) GO -CREATE INDEX idx_datai_container ON data_instance (tenantId, containerId, containerType, name) +CREATE INDEX idx_datai_container ON data_instance (containerId, containerType, name) GO CREATE TABLE dependency ( @@ -798,7 +796,7 @@ CREATE TABLE group_ ( PRIMARY KEY (tenantid, id) ) GO -CREATE INDEX idx_group_name ON group_ (tenantid, parentPath, name); +CREATE INDEX idx_group_name ON group_ (parentPath, name); GO CREATE TABLE role ( tenantid NUMERIC(19, 0) NOT NULL, @@ -815,7 +813,7 @@ CREATE TABLE role ( ) GO -CREATE INDEX idx_role_name ON role (tenantid, name) +CREATE INDEX idx_role_name ON role (name) GO CREATE TABLE user_ ( @@ -838,7 +836,7 @@ CREATE TABLE user_ ( ) GO -CREATE INDEX idx_user_name ON user_ (tenantid, userName) +CREATE INDEX idx_user_name ON user_ (userName) GO CREATE TABLE user_login ( @@ -872,7 +870,7 @@ CREATE TABLE user_contactinfo ( GO ALTER TABLE user_contactinfo ADD CONSTRAINT fk_contact_user FOREIGN KEY (tenantid, userId) REFERENCES user_ (tenantid, id) ON DELETE CASCADE GO -CREATE INDEX idx_user_contactinfo ON user_contactinfo (userId, tenantid, personal) +CREATE INDEX idx_user_contactinfo ON user_contactinfo (userId, personal) GO @@ -886,7 +884,7 @@ CREATE TABLE custom_usr_inf_def ( ) GO -CREATE INDEX idx_custom_usr_inf_def_name ON custom_usr_inf_def (tenantid, name) +CREATE INDEX idx_custom_usr_inf_def_name ON custom_usr_inf_def (name) GO CREATE TABLE custom_usr_inf_val ( @@ -1071,6 +1069,8 @@ CREATE TABLE job_desc ( PRIMARY KEY (tenantid, id) ) GO +CREATE INDEX idx_job_desc_id ON job_desc(id) +GO CREATE TABLE job_param ( tenantid NUMERIC(19, 0) NOT NULL, @@ -1081,7 +1081,7 @@ CREATE TABLE job_param ( PRIMARY KEY (tenantid, id) ) GO -CREATE INDEX idx_job_param_tenant_jobid ON job_param (tenantid, jobDescriptorId) +CREATE INDEX idx_job_param_jobid ON job_param (jobDescriptorId) GO @@ -1096,11 +1096,13 @@ CREATE TABLE job_log ( PRIMARY KEY (tenantid, id) ) GO - ALTER TABLE job_param ADD CONSTRAINT fk_job_param_jobid FOREIGN KEY (tenantid, jobDescriptorId) REFERENCES job_desc(tenantid, id) ON DELETE CASCADE GO ALTER TABLE job_log ADD CONSTRAINT fk_job_log_jobid FOREIGN KEY (tenantid, jobDescriptorId) REFERENCES job_desc(tenantid, id) ON DELETE CASCADE GO +CREATE INDEX idx_job_log_jobdescid ON job_log(jobdescriptorid) +GO + CREATE TABLE form_mapping ( tenantId NUMERIC(19, 0) NOT NULL, id NUMERIC(19, 0) NOT NULL, @@ -1151,7 +1153,7 @@ CREATE TABLE bar_resource ( PRIMARY KEY (tenantId, id) ) GO -CREATE INDEX idx_bar_resource ON bar_resource (tenantId, process_id, type, name) +CREATE INDEX idx_bar_resource ON bar_resource (process_id, type, name) GO CREATE TABLE temporary_content ( id NUMERIC(19, 0) NOT NULL, @@ -1179,7 +1181,7 @@ CREATE TABLE tenant_resource ( PRIMARY KEY (tenantId, id) ) GO -CREATE INDEX idx_tenant_resource ON tenant_resource (tenantId, type, name) +CREATE INDEX idx_tenant_resource ON tenant_resource (type, name) GO CREATE TABLE icon ( tenantId NUMERIC(19, 0) NOT NULL,