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

Optimize service instances SQL query efficiency #3954

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

a-b
Copy link
Member

@a-b a-b commented Sep 6, 2024

Service instances cannot have duplicate values due to the primary key constraint on GUID, so using distinct is not only redundant but also affects query performance.

Co-authored-by: @shahnavaz

  • 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

a-b and others added 2 commits September 6, 2024 11:01
Service instances cannot have duplicate values due to the primary key constraint on GUID, so using distinct is not only redundant but also affects query performance.

Co-authored-by: Shahnavaz Valayil <shahnavaz.valayil@broadcom.com>
@a-b a-b changed the title Performace improvement Optimize service instances SQL query efficiency Sep 6, 2024
Copy link
Member

@sethboyles sethboyles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unfortunate we didn't have a test in place for why this is needed, but I'm adding one with this PR:

#3955

We need this DISTINCT clause due to the left join on service_instance_shares. If a Service Instance has been shared with two or more spaces the user belongs to, that will result in duplicate SIs in the query results

@a-b
Copy link
Member Author

a-b commented Sep 7, 2024

@sethboyles, thanks for your feedback. At least we improved test coverage. We will keep iterating on this PR to find alternative ways to improve query performance. Our current goals are:

  1. [must] Find possible SQL optimizations for service instances query.
  2. [attractive] Keep it SQL dialect agnostic.

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