perf: skip org unit/period resolution in dimension recommendations [2.40]#24277
Open
jason-p-pickering wants to merge 1 commit into
Open
perf: skip org unit/period resolution in dimension recommendations [2.40]#24277jason-p-pickering wants to merge 1 commit into
jason-p-pickering wants to merge 1 commit into
Conversation
….40] Backport of master commit f61988a (PR #24264) onto 2.40. The /api/dimensions/recommendations endpoint resolved every dimension on the request via DataQueryService.getFromRequest, including ou:LEVEL-*. On a large hierarchy this hydrates all org units at the level as full entities and sorts them (~4.5s CPU, ~3.2 GB allocated in production profiling) -- but getRecommendedDimensions only reads the data (dx) dimension's data elements/program indicators, so the org unit (and period) resolution is discarded. Scope the request to the dx dimension before resolving, so getFromRequest never resolves/hydrates the unused dimensions. Behaviour-equivalent for the sole caller (DimensionController sets only the dimension param), with no change to DataQueryService/getOrganisationUnitsAtLevels callers. 2.40 adaptations vs the master commit: - DATA_X_DIM_ID is imported from DimensionalObject (2.40 predates the DimensionConstants extraction). - The unit test mocks CurrentUserService (2.40's service still reads the current user via the injected field) instead of master's static CurrentUserUtil / UserDetails.empty() setup. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Backport of master commit
f61988aa36(PR #24264) onto2.40./api/dimensions/recommendationsresolved every dimension on the request viaDataQueryService.getFromRequest, includingou:LEVEL-*. On a large hierarchy this hydrates all org units at the level as full entities and sorts them (~4.5s CPU, ~3.2 GB allocated in production profiling) — butgetRecommendedDimensionsonly reads the data (dx) dimension's data elements / program indicators, so the org-unit (and period) resolution is pure discarded work.This scopes the request to the
dxdimension before resolving, sogetFromRequestnever resolves/hydrates the unused dimensions. Behaviour-equivalent for the sole caller (DimensionControllersets only thedimensionparam); no change toDataQueryService/getOrganisationUnitsAtLevelscallers.2.40 adaptations vs the master commit
DATA_X_DIM_IDis imported fromDimensionalObject— 2.40 predates theDimensionConstantsextraction.CurrentUserService(2.40's service still reads the current user via the injected field) instead of master's staticCurrentUserUtil/UserDetails.empty()setup.Testing
DefaultAnalyticsDimensionServiceTest#getRecommendedDimensionsResolvesOnlyDataDimension(new) — asserts only thedxdimension reachesgetFromRequest;ou/peare stripped. Passes.🤖 Generated with Claude Code