From cdc9aad738161f0a1b9078301b0b89325fc4cecf Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Tue, 7 Jan 2020 09:53:43 +1100 Subject: [PATCH] feat(matrix): add indexes to optimise queries --- ...reate_indexes_on_latest_pact_publications.rb | 17 +++++++++++++++++ ...07_create_indexes_on_latest_verifications.rb | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 db/migrations/20200106_create_indexes_on_latest_pact_publications.rb create mode 100644 db/migrations/20200107_create_indexes_on_latest_verifications.rb diff --git a/db/migrations/20200106_create_indexes_on_latest_pact_publications.rb b/db/migrations/20200106_create_indexes_on_latest_pact_publications.rb new file mode 100644 index 000000000..e0b024d4d --- /dev/null +++ b/db/migrations/20200106_create_indexes_on_latest_pact_publications.rb @@ -0,0 +1,17 @@ +Sequel.migration do + up do + alter_table(:latest_pact_publication_ids_for_consumer_versions) do + add_index [:consumer_id], name: 'ndx_latest_pact_publications_consumer_id' + add_index [:provider_id], name: 'ndx_latest_pact_publications_provider_id' + add_index [:consumer_version_id], name: 'ndx_latest_pact_publications_cv_id' + end + end + + down do + alter_table(:latest_pact_publication_ids_for_consumer_versions) do + drop_index [:consumer_id], name: 'ndx_latest_pact_publications_consumer_id' + drop_index [:provider_id], name: 'ndx_latest_pact_publications_provider_id' + drop_index [:consumer_version_id], name: 'ndx_latest_pact_publications_cv_id' + end + end +end diff --git a/db/migrations/20200107_create_indexes_on_latest_verifications.rb b/db/migrations/20200107_create_indexes_on_latest_verifications.rb new file mode 100644 index 000000000..a9c6cf8e1 --- /dev/null +++ b/db/migrations/20200107_create_indexes_on_latest_verifications.rb @@ -0,0 +1,17 @@ +Sequel.migration do + up do + alter_table(:latest_verification_id_for_pact_version_and_provider_version) do + add_index [:consumer_id], name: 'ndx_latest_verification_consumer_id' + add_index [:provider_id], name: 'ndx_latest_verification_provider_id' + add_index [:provider_version_id], name: 'ndx_latest_verification_provider_version_id' + end + end + + down do + alter_table(:latest_verification_id_for_pact_version_and_provider_version) do + drop_index [:consumer_id], name: 'ndx_latest_verification_consumer_id' + drop_index [:provider_id], name: 'ndx_latest_verification_provider_id' + drop_index [:provider_version_id], name: 'ndx_latest_verification_provider_version_id' + end + end +end