mirror of
https://github.com/ansible/awx.git
synced 2026-07-31 09:59:55 -02:30
* AAP-82745 — Replace O(N) correlated subqueries in org list with bulk aggregation The org list endpoint computed per-org user and admin counts using two correlated subqueries against roleuserassignment — one per org per role type. At scale this was the #1 worst query in the customer DB (677ms mean, 336K calls, 3,801 min total DB time). Replace with a single flat conditional-aggregation query that scans roleuserassignment once regardless of org count. Also simplify the detail view to use direct .count() calls and add a query count regression test. * Remove dead code: org_counts is always populated after refactor * Address review feedback on detail view and test - Detail view: combine two .count() calls into single .aggregate() with conditional counts, matching the list-view pattern - Use .update() in else branch for consistency with if branch - Remove redundant setup_managed_roles fixture (transitive via organization_resource_creator) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>