Remove nano_view_queue from unscoped MDM commands list query#45674
Remove nano_view_queue from unscoped MDM commands list query#45674raju249 wants to merge 1 commit into
Conversation
The view's baked-in ORDER BY forces MySQL to materialize the full three-way join and sort it before any outer LIMIT applies, defeating pagination. The Apple branch in getMDMCommandsSubqueries now joins the underlying nano_* tables directly, mirroring the host-scoped path that already bypasses the view. Column shape and filter semantics are unchanged. Refs fleetdm#44509.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR refactors the Apple MDM commands query in 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hello @getvictor - Please take a look. 🙇 Thanks! 🙏 🙇 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #45674 +/- ##
==========================================
- Coverage 66.75% 66.75% -0.01%
==========================================
Files 2745 2745
Lines 219361 219359 -2
Branches 10840 10840
==========================================
- Hits 146438 146424 -14
- Misses 59695 59704 +9
- Partials 13228 13231 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
assigning to @JordanMontgomery for review |
Drops
nano_view_queuefrom the Apple branch of the unscoped commands list and joins the underlyingnano_*tables directly. The view's definition bakes inORDER BY q.priority DESC, q.created_at, which MySQL re-materializes on every query — the outerLIMITcan't push past it, so each unscoped list call pays the full sort cost over the post-join row set regardless of page size.This is the same join shape the host-scoped path already uses (see
listMDMCommandsByHostIdentifier), so I followed that pattern. Column output is identical to what the view was producing, which is why no test updates were needed — all the existingTestListMDMCommands*cases pass without modification.Scope of this PR is just the hot caller. The view itself isn't touched. The issue notes other call sites (
vpp.go,apple_mdm.go) still go through it, and that dropping theORDER BYfrom the view's definition would be the durable fix. Both feel like separate PRs — the audit work for other call sites is non-trivial, and modifying the view risks silently breaking any consumer that relied on its implicit ordering. Happy to follow up on either.Refs #44509.
Checklist for submitter
TestListMDMCommands*coverage exercises this path and passes unchanged. No new tests added — see rationale above.Summary by CodeRabbit
Bug Fixes