From 188602533074878a4550e8effa82d4453454601d Mon Sep 17 00:00:00 2001 From: mlm483 <128052931+mlm483@users.noreply.github.com> Date: Mon, 14 Aug 2023 11:43:03 -0400 Subject: [PATCH 1/4] [BI-1771] - added create_indexes.sql --- .../brapi/properties/application.properties | 2 +- src/main/resources/brapi/sql/create_indexes.sql | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/brapi/sql/create_indexes.sql diff --git a/src/main/resources/brapi/properties/application.properties b/src/main/resources/brapi/properties/application.properties index 48d433aa4..fc53bf123 100644 --- a/src/main/resources/brapi/properties/application.properties +++ b/src/main/resources/brapi/properties/application.properties @@ -21,7 +21,7 @@ server.servlet.context-path=/brapi/v2 spring.datasource.url=jdbc:postgresql://${BRAPI_DB_SERVER}/${BRAPI_DB} spring.datasource.username=${BRAPI_DB_USER} spring.datasource.password=${BRAPI_DB_PASSWORD} -spring.datasource.data=classpath:/sql/species.sql +spring.datasource.data=classpath:/sql/species.sql, classpath:/sql/create_indexes.sql spring.datasource.driver-class-name=org.postgresql.Driver diff --git a/src/main/resources/brapi/sql/create_indexes.sql b/src/main/resources/brapi/sql/create_indexes.sql new file mode 100644 index 000000000..4963c4d91 --- /dev/null +++ b/src/main/resources/brapi/sql/create_indexes.sql @@ -0,0 +1,13 @@ +-- Indexes to improve read performance of Germplasm operations. +CREATE INDEX CONCURRENTLY "pedigree_edge_this_node_id" ON pedigree_edge (this_node_id); +CREATE INDEX CONCURRENTLY "pedigree_edge_connected_node_id" ON pedigree_edge (connceted_node_id); +CREATE INDEX CONCURRENTLY "pedigree_edge_edge_type" ON pedigree_edge (edge_type); +CREATE INDEX CONCURRENTLY "program_external_references_program_entity_id" ON program_external_references (program_entity_id); +CREATE INDEX CONCURRENTLY "external_reference_composite" ON external_reference (external_reference_source, external_reference_id); +CREATE INDEX CONCURRENTLY "program_additional_info_composite" ON program_additional_info (additional_info_id, program_entity_id); +CREATE INDEX CONCURRENTLY "list_list_name" ON list (list_name); +CREATE INDEX CONCURRENTLY "pedigree_node_germplasm_id" ON pedigree_node (germplasm_id); +CREATE INDEX CONCURRENTLY "germplasm_additional_info_germplasm_entity_id" ON germplasm_additional_info (germplasm_entity_id); +CREATE INDEX CONCURRENTLY "germplasm_external_references_germplasm_entity_id" ON germplasm_external_references (germplasm_entity_id); +CREATE INDEX CONCURRENTLY "germplasm_synonym_germplasm_id" ON germplasm_synonym (germplasm_id); +CREATE INDEX CONCURRENTLY "germplasm_taxon_germplasm_id" ON germplasm_taxon (germplasm_id); \ No newline at end of file From 9d7e2db70bb13736b7b7aa09acffc3d61aba0ee5 Mon Sep 17 00:00:00 2001 From: mlm483 <128052931+mlm483@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:47:51 -0400 Subject: [PATCH 2/4] [BI-1771] - made create_indexes.sql idempotent added IF NOT EXISTS to CREATE INDEX statements --- .../resources/brapi/sql/create_indexes.sql | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/main/resources/brapi/sql/create_indexes.sql b/src/main/resources/brapi/sql/create_indexes.sql index 4963c4d91..6c0772bfd 100644 --- a/src/main/resources/brapi/sql/create_indexes.sql +++ b/src/main/resources/brapi/sql/create_indexes.sql @@ -1,13 +1,28 @@ +-- See the NOTICE file distributed with this work for additional information +-- regarding copyright ownership. +-- +-- Licensed 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. + -- Indexes to improve read performance of Germplasm operations. -CREATE INDEX CONCURRENTLY "pedigree_edge_this_node_id" ON pedigree_edge (this_node_id); -CREATE INDEX CONCURRENTLY "pedigree_edge_connected_node_id" ON pedigree_edge (connceted_node_id); -CREATE INDEX CONCURRENTLY "pedigree_edge_edge_type" ON pedigree_edge (edge_type); -CREATE INDEX CONCURRENTLY "program_external_references_program_entity_id" ON program_external_references (program_entity_id); -CREATE INDEX CONCURRENTLY "external_reference_composite" ON external_reference (external_reference_source, external_reference_id); -CREATE INDEX CONCURRENTLY "program_additional_info_composite" ON program_additional_info (additional_info_id, program_entity_id); -CREATE INDEX CONCURRENTLY "list_list_name" ON list (list_name); -CREATE INDEX CONCURRENTLY "pedigree_node_germplasm_id" ON pedigree_node (germplasm_id); -CREATE INDEX CONCURRENTLY "germplasm_additional_info_germplasm_entity_id" ON germplasm_additional_info (germplasm_entity_id); -CREATE INDEX CONCURRENTLY "germplasm_external_references_germplasm_entity_id" ON germplasm_external_references (germplasm_entity_id); -CREATE INDEX CONCURRENTLY "germplasm_synonym_germplasm_id" ON germplasm_synonym (germplasm_id); -CREATE INDEX CONCURRENTLY "germplasm_taxon_germplasm_id" ON germplasm_taxon (germplasm_id); \ No newline at end of file +CREATE INDEX CONCURRENTLY IF NOT EXISTS "pedigree_edge_this_node_id" ON pedigree_edge (this_node_id); +CREATE INDEX CONCURRENTLY IF NOT EXISTS "pedigree_edge_connected_node_id" ON pedigree_edge (connceted_node_id); +CREATE INDEX CONCURRENTLY IF NOT EXISTS "pedigree_edge_edge_type" ON pedigree_edge (edge_type); +CREATE INDEX CONCURRENTLY IF NOT EXISTS "program_external_references_program_entity_id" ON program_external_references (program_entity_id); +CREATE INDEX CONCURRENTLY IF NOT EXISTS "external_reference_composite" ON external_reference (external_reference_source, external_reference_id); +CREATE INDEX CONCURRENTLY IF NOT EXISTS "program_additional_info_composite" ON program_additional_info (additional_info_id, program_entity_id); +CREATE INDEX CONCURRENTLY IF NOT EXISTS "list_list_name" ON list (list_name); +CREATE INDEX CONCURRENTLY IF NOT EXISTS "pedigree_node_germplasm_id" ON pedigree_node (germplasm_id); +CREATE INDEX CONCURRENTLY IF NOT EXISTS "germplasm_additional_info_germplasm_entity_id" ON germplasm_additional_info (germplasm_entity_id); +CREATE INDEX CONCURRENTLY IF NOT EXISTS "germplasm_external_references_germplasm_entity_id" ON germplasm_external_references (germplasm_entity_id); +CREATE INDEX CONCURRENTLY IF NOT EXISTS "germplasm_synonym_germplasm_id" ON germplasm_synonym (germplasm_id); +CREATE INDEX CONCURRENTLY IF NOT EXISTS "germplasm_taxon_germplasm_id" ON germplasm_taxon (germplasm_id); \ No newline at end of file From b2caca51311610d7b10950d261481eae375006ee Mon Sep 17 00:00:00 2001 From: mlm483 <128052931+mlm483@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:49:22 -0400 Subject: [PATCH 3/4] [BI-1771] - fixed comment in species.sql --- src/main/resources/brapi/sql/species.sql | 30 +++++++++++------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/main/resources/brapi/sql/species.sql b/src/main/resources/brapi/sql/species.sql index 3134f6e6d..c57dd2ac9 100644 --- a/src/main/resources/brapi/sql/species.sql +++ b/src/main/resources/brapi/sql/species.sql @@ -1,19 +1,17 @@ -/* - * See the NOTICE file distributed with this work for additional information - * regarding copyright ownership. - * - * Licensed 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. - */ +-- See the NOTICE file distributed with this work for additional information +-- regarding copyright ownership. +-- +-- Licensed 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. INSERT INTO crop (id, crop_name) VALUES ('1', 'Blueberry') ON CONFLICT DO NOTHING; INSERT INTO crop (id, crop_name) VALUES ('2', 'Salmon') ON CONFLICT DO NOTHING; From 81ba0b66a9b9069ec4dbe1f5a3654d4c19b31e70 Mon Sep 17 00:00:00 2001 From: mlm483 <128052931+mlm483@users.noreply.github.com> Date: Tue, 15 Aug 2023 11:01:57 -0400 Subject: [PATCH 4/4] [BI-1771] - updated application.properties --- src/main/resources/brapi/properties/application.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/brapi/properties/application.properties b/src/main/resources/brapi/properties/application.properties index fc53bf123..32fc7437f 100644 --- a/src/main/resources/brapi/properties/application.properties +++ b/src/main/resources/brapi/properties/application.properties @@ -21,12 +21,12 @@ server.servlet.context-path=/brapi/v2 spring.datasource.url=jdbc:postgresql://${BRAPI_DB_SERVER}/${BRAPI_DB} spring.datasource.username=${BRAPI_DB_USER} spring.datasource.password=${BRAPI_DB_PASSWORD} -spring.datasource.data=classpath:/sql/species.sql, classpath:/sql/create_indexes.sql spring.datasource.driver-class-name=org.postgresql.Driver -spring.jpa.hibernate.ddl-auto=update +spring.jpa.hibernate.ddl-auto=create-only spring.jpa.show-sql=false +spring.jpa.properties.hibernate.hbm2ddl.import_files=sql/species.sql, sql/create_indexes.sql spring.mvc.dispatch-options-request=true