Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance sorting SDG records #4342

Merged
merged 1 commit into from
Jan 30, 2021
Merged

Conversation

javierm
Copy link
Member

@javierm javierm commented Jan 30, 2021

Backgound

We noticed there was a performance issue while browsing the SDG Management section and when one of our tests started failing sometimes because the request to the relations#index controller took too long.

The issue proved to be SDG::Target#<=>. This method calls .goal for each target, meaning we were generating 169 database queries when sorting all targets.

Objectives

  • Remove a performance bottleneck
  • Reduce the number of times our test suite fails due to requests taking longer than Capybara's wait time
  • Simplify the code sorting goals and targets

We noticed there was a performance issue while browsing the SDG
Management section and when one of our tests started failing sometimes
because the request to the relations#index controller took too long.

The issue proved to be `SDG::Target#<=>`. This method calls `.goal` for
each target, meaning we were generating 169 database queries when
sorting all targets.

So we're comparing codes directly to minimize the number of database
queries and improve performance. Requests to the relations index take
now less than third of the time they used to take.
@javierm javierm added the SDG United Nations Sustainable Development Goals label Jan 30, 2021
@javierm javierm self-assigned this Jan 30, 2021
@javierm javierm added this to Reviewing in Consul Democracy via automation Jan 30, 2021
@taitus taitus self-assigned this Jan 30, 2021
Consul Democracy automation moved this from Reviewing to Testing Jan 30, 2021
@javierm javierm merged commit 0f52d22 into master Jan 30, 2021
Consul Democracy automation moved this from Testing to Release 1.3.0 Jan 30, 2021
@javierm javierm deleted the sdg_sort_performance branch January 30, 2021 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Flaky bug SDG United Nations Sustainable Development Goals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants