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 = '');