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

Remove more inefficient counting #3067

Merged

Conversation

will-gant
Copy link
Contributor

@will-gant will-gant commented Nov 17, 2022

A short explanation of the proposed change:

Small optimizations to a few DB queries related to counting.

An explanation of the use cases your change solves

Two small things:

  1. In a few more places, switches to use Sequel's any? and empty? methods instead of count when all we want to know is whether a non-zero number of matching records exist. Essentially a follow-up to Misc db optimizations #3052
  2. In a few places we use formulations like resource.associated_resources.map(&:other_associated_resources), which results in a single query to fetch associated_resources and then, for each one found, a separate query to count its other_associated_resources. This can be replaced with a single query with a join and empty?\any?.

Links to any other associated PRs

n/a

  • 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

app/actions/service_offering_delete.rb Outdated Show resolved Hide resolved
app/actions/space_delete.rb Outdated Show resolved Hide resolved
lib/services/service_brokers/v2/catalog.rb Outdated Show resolved Hide resolved
@will-gant will-gant force-pushed the more-counting-optimizations branch from a75d27d to 661fb33 Compare November 17, 2022 14:39
@philippthun philippthun merged commit 2adc01f into cloudfoundry:main Nov 18, 2022
@will-gant will-gant mentioned this pull request Nov 30, 2022
5 tasks
will-gant added a commit to sap-contributions/cloud_controller_ng that referenced this pull request Dec 16, 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