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 MySQL queries that aggregate MDM profile statuses for Apple hosts #22252

Merged
merged 9 commits into from
Sep 24, 2024

Conversation

gillespi314
Copy link
Contributor

@gillespi314 gillespi314 commented Sep 19, 2024

Issue #22122

  • Addresses performance issues seen in deployments with larger-sized host_mdm_apple_profiles and host_mdm_apple_declarations tables (where tables scale based on number of hosts multiplied by number of profiles)
    • Improves performance of MDM profiles summary endpoint
    • Improves performance when filtering hosts by OS settings status (i.e. MDM profiles status)

See areas for future improvement below.

Checklist for submitter

If some of the following don't apply, delete the relevant line.

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
  • Added/updated tests
  • Manual QA for all new/changed functionality

Copy link

codecov bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 97.77778% with 2 lines in your changes missing coverage. Please review.

Project coverage is 65.23%. Comparing base (90c04ee) to head (acee93f).
Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
server/datastore/mysql/apple_mdm.go 97.77% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #22252      +/-   ##
==========================================
+ Coverage   65.20%   65.23%   +0.02%     
==========================================
  Files        1495     1495              
  Lines      117110   117187      +77     
  Branches     3512     3512              
==========================================
+ Hits        76365    76449      +84     
+ Misses      33627    33619       -8     
- Partials     7118     7119       +1     
Flag Coverage Δ
backend 66.53% <97.77%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gillespi314 gillespi314 marked this pull request as ready for review September 19, 2024 19:52
@gillespi314 gillespi314 requested a review from a team as a code owner September 19, 2024 19:52
georgekarrv
georgekarrv previously approved these changes Sep 19, 2024
Copy link
Member

@georgekarrv georgekarrv left a comment

Choose a reason for hiding this comment

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

LGTM but would love another set of eyes on this.

@roperzh
Copy link
Member

roperzh commented Sep 23, 2024

#22122

roperzh
roperzh previously approved these changes Sep 23, 2024
Copy link
Member

@roperzh roperzh left a comment

Choose a reason for hiding this comment

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

the query looks scary but it's very nice to read and way better than the old one. LGTM 🎉

server/datastore/mysql/apple_mdm.go Show resolved Hide resolved
Copy link
Member

@roperzh roperzh left a comment

Choose a reason for hiding this comment

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

LGTM, seems like an unrelated test failed but I'd be nice to see all tests pass before approving.

could you either remove the new TODO or add parenthesis to the if clause? I think it'll confuse people if we leave it there.

server/datastore/mysql/hosts.go Outdated Show resolved Hide resolved
@gillespi314 gillespi314 changed the title Optimize query for Apple MDM profiles summary Improve MySQL queries that aggregate MDM profile statuses for Apple hosts Sep 24, 2024
@gillespi314
Copy link
Contributor Author

gillespi314 commented Sep 24, 2024

Areas for future improvement:

  • Disk encryption summary and filters
  • Windows profiles summary and filters
  • Other places where we're using sub-selects on MDM-related tables?

@gillespi314 gillespi314 merged commit ea0175e into main Sep 24, 2024
13 of 15 checks passed
@gillespi314 gillespi314 deleted the 22122-mdm-profile-summary branch September 24, 2024 19:47
@gillespi314
Copy link
Contributor Author

Failing tests are known to be broken/flaky and are not related to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants