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

Use sub query for user visibility filter #3537

Merged
merged 1 commit into from
Dec 5, 2023
Merged

Conversation

johha
Copy link
Contributor

@johha johha commented Dec 5, 2023

In case there are many service instances related db queries might become very complex:

SELECT * FROM \"services\" WHERE ((\"services\".\"id\" IN (7)) AND (\"id\" IN (<super long list of service ids>)))

This can lead to high memory consumption on the api VMs and can also cause memory bloats as everything is loaded into memory.

With this change we change the query to use a sub query instead:

SELECT * FROM \"services\" WHERE ((\"services\".\"id\" IN (7)) AND (\"id\" IN (SELECT DISTINCT \"service_id\" FROM \"service_plans\")))
  • 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

In case there are many service instances related db queries
might become very complex:
```
SELECT * FROM \"services\" WHERE ((\"services\".\"id\" IN (7)) AND (\"id\" IN (<super long list of service ids>)))
```

This can lead to high memory consumption on the api VMs and can also cause memory bloats as everything is loaded into memory.

With this change we change the query to use a sub query instead:
```
SELECT * FROM \"services\" WHERE ((\"services\".\"id\" IN (7)) AND (\"id\" IN (SELECT DISTINCT \"service_id\" FROM \"service_plans\")))
```

Co-authored-by: Philipp Thun <[email protected]>
@johha johha marked this pull request as ready for review December 5, 2023 15:16
@johha johha merged commit 0494c38 into main Dec 5, 2023
5 checks passed
@johha johha deleted the v2-service-visibility-filter branch December 5, 2023 15:17
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.

2 participants