Skip to content

backport: perf: pre-filter geoFeatures org units by geometry [2.43]#24491

Merged
jason-p-pickering merged 2 commits into
2.43from
perf/geofeatures-geom-prefilter-43_2.43
Jul 20, 2026
Merged

backport: perf: pre-filter geoFeatures org units by geometry [2.43]#24491
jason-p-pickering merged 2 commits into
2.43from
perf/geofeatures-geom-prefilter-43_2.43

Conversation

@jason-p-pickering

@jason-p-pickering jason-p-pickering commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Backport of #24279

* perf: pre-filter geoFeatures org units by geometry

geoFeatures resolves the `ou` dimension into full OrganisationUnit
entities, then discards every unit without geometry in-memory. On a
large hierarchy (Nigeria prod: ~255k level-5 units, all null-geometry)
this hydrates a quarter-million entities — ~7.6s CPU and ~4.7 GB
allocated — only to return [].

Thread an optional `geometryOnly` flag from DataQueryRequest through
DimensionalObjectProvider and OrganisationUnitService down to
HibernateOrganisationUnitStore, which appends `and o.geometry is not
null`. Default off, so all other callers dispatch the original 2-arg
methods unchanged. Skipped in geoJsonAttribute (coordinateField) mode,
where coordinates come from an attribute and the geometry column may be
null. The in-memory filter remains the precise final gate.

When the geometry-filtered resolution is empty, the E7143 empty-dimension
guard is suppressed so geoFeatures still returns 200 [] rather than an
error.

Validated on production (Nigeria, deployed on 2.40): a comparable
high-level layer dropped from ~8.6s/4.7GB to 14ms/747KB.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor: bundle getDimension args into DimensionResolveOptions

The private getDimension dispatcher grew to 8 parameters when geometryOnly
was threaded through, tripping SonarQube java:S107 (>7 parameters). Bundle
the five resolution options (relativePeriodDate, displayProperty, allowNull,
inputIdScheme, geometryOnly) into a private DimensionResolveOptions record,
bringing the method to 4 parameters. Behaviour is unchanged; contained
entirely within DefaultDataQueryService.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jason-p-pickering
jason-p-pickering requested review from a team, david-mackessy, jbee and netroms July 18, 2026 07:59
@jason-p-pickering jason-p-pickering added the run-api-analytics-tests Enables analytics e2e tests label Jul 18, 2026
@jason-p-pickering jason-p-pickering changed the title backport: perf: pre-filter geoFeatures org units by geometry backport: perf: pre-filter geoFeatures org units by geometry [2.43] Jul 19, 2026
@sonarqubecloud

Copy link
Copy Markdown

@jason-p-pickering
jason-p-pickering merged commit 31819c1 into 2.43 Jul 20, 2026
18 checks passed
@jason-p-pickering
jason-p-pickering deleted the perf/geofeatures-geom-prefilter-43_2.43 branch July 20, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-api-analytics-tests Enables analytics e2e tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants