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

Don't check org quota visibility if user reads globally #2876

Merged

Conversation

will-gant
Copy link
Contributor

@will-gant will-gant commented Jul 19, 2022

  • A short explanation of the proposed change:

Adopts the approach taken in #2650 and #2638 to eliminate the need for DB queries in the org quotas presenter when the user is a global reader.

  • An explanation of the use cases your change solves

This noticeably speeds up GET /v3/organization_quotas for global readers, which currently drags when constructing the relationships block of each response object. On foundations with thousands of orgs constructing the relationships block currently take a very long time (I measured an average of 117 seconds on one foundation with 65,000 orgs, and that's with per_page=50 (versus 0.035 seconds for the equivalent v2 endpoint)). Currently, a separate DB query is made for each org that org quotas have a relationship with in order to determine whether it is visible to the user - even when we know the user is a global reader.

This change skips these expensive queries for users with an admin, admin read-only or global auditor role, and in a test environment with 20,000 orgs, each assigned its own org quota, /v3/organization_quotas?per_page=50 now takes 0.533 seconds.

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

@will-gant will-gant force-pushed the org-quotas-fewer-db-queries branch from 838932a to 6b4dbbc Compare July 19, 2022 16:56
@philippthun philippthun self-requested a review July 20, 2022 07:47
@philippthun philippthun self-assigned this Jul 20, 2022
@will-gant will-gant force-pushed the org-quotas-fewer-db-queries branch from 6b4dbbc to f6e5c86 Compare July 20, 2022 12:29
@philippthun
Copy link
Member

Oh, spec/request/organization_quotas_spec.rb also checks the error message and needs to be adapted.

@will-gant will-gant force-pushed the org-quotas-fewer-db-queries branch from f6e5c86 to a41415f Compare July 20, 2022 13:35
@philippthun philippthun merged commit f3e0274 into cloudfoundry:main Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants