From 03057f115029cef542a242272f7ae316b252d939 Mon Sep 17 00:00:00 2001 From: Jason Pickering Date: Thu, 16 Apr 2026 15:58:12 +0200 Subject: [PATCH] fix: Add index to support trim job [DHIS2-21330] (2.43) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backport of #23631 (5846b9a6ab) to 2.43 as migration V2_43_71. The master migration V2_44_1 uses 'create index if not exists', so systems upgrading from 2.43 to 2.44 skip it. (cherry picked from commit 5846b9a6abc6e6319f59088a3dfcd53c441b9553) 🤖 AI Assisted --- .../2.43/V2_43_71__add_datavalue_null_empty_trim_index.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 dhis-2/dhis-support/dhis-support-db-migration/src/main/resources/org/hisp/dhis/db/migration/2.43/V2_43_71__add_datavalue_null_empty_trim_index.sql diff --git a/dhis-2/dhis-support/dhis-support-db-migration/src/main/resources/org/hisp/dhis/db/migration/2.43/V2_43_71__add_datavalue_null_empty_trim_index.sql b/dhis-2/dhis-support/dhis-support-db-migration/src/main/resources/org/hisp/dhis/db/migration/2.43/V2_43_71__add_datavalue_null_empty_trim_index.sql new file mode 100644 index 000000000000..2e6a028aec98 --- /dev/null +++ b/dhis-2/dhis-support/dhis-support-db-migration/src/main/resources/org/hisp/dhis/db/migration/2.43/V2_43_71__add_datavalue_null_empty_trim_index.sql @@ -0,0 +1,7 @@ +-- Partial index to support DataValueTrimJob efficiently. +-- Only indexes rows where value is null or empty and not yet deleted, +-- which are the candidates for soft-deletion by the trim job. +-- Expected to be tiny in a healthy system (near-zero rows match). +create index if not exists idx_datavalue_null_empty_trim + on datavalue (dataelementid) + where deleted = false and (value is null or value = '');