-
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optimise latest_pact_publications_by_consumer_versions
- Loading branch information
Showing
4 changed files
with
34 additions
and
7 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
db/ddl_statements/latest_pact_publications_by_consumer_versions.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
def latest_pact_publications_by_consumer_versions_v2(connection = nil) | ||
"select app.* | ||
from latest_pact_publication_ids_for_consumer_versions lpp | ||
inner join all_pact_publications app | ||
on lpp.consumer_version_id = app.consumer_version_id | ||
and lpp.pact_publication_id = app.id | ||
and lpp.provider_id = app.provider_id" | ||
end | ||
|
||
# Don't need all the join keys, just pact_publication_id | ||
def latest_pact_publications_by_consumer_versions_v3(connection) | ||
"select app.* | ||
from latest_pact_publication_ids_for_consumer_versions lpp | ||
inner join all_pact_publications app | ||
on lpp.pact_publication_id = app.id" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
db/migrations/20191030_optimise_latest_pact_publications_by_consumer_versions_.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require_relative '../ddl_statements' | ||
|
||
Sequel.migration do | ||
up do | ||
create_or_replace_view(:latest_pact_publications_by_consumer_versions, | ||
latest_pact_publications_by_consumer_versions_v3(self)) | ||
end | ||
|
||
down do | ||
create_or_replace_view(:latest_pact_publications_by_consumer_versions, | ||
latest_pact_publications_by_consumer_versions_v2(self)) | ||
end | ||
end |