Repository navigation
fix: Add index to support trim job [DHIS2-21330] (2.43) - #25512
Merged
Merged
Conversation
|
jbee
approved these changes
Oct 7, 2026
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.



Backport of #23631 (5846b9a) to 2.43.
Implements DHIS2-21330
The DataValueTrimJob (introduced in 2.41) soft-deletes data values with null/empty values for non-zero-significant data elements. Its query required a full sequential scan of the datavalue table, more than 10 seconds on a 63M-row system, scaling linearly with table size.
A partial index on
(dataelementid) WHERE deleted = false AND (value IS NULL OR value = '')reduces this to ~8ms. The index is expected to be near-empty in healthy systems, so the storage and write overhead are negligible.The migration is added as
V2_43_71. The master migrationV2_44_1usescreate index if not exists, so systems upgrading from 2.43 to 2.44 skip it.🤖 AI Assisted