diff --git a/dspace-api/src/main/java/org/dspace/content/dao/impl/ItemForMetadataEnhancementUpdateDAOImpl.java b/dspace-api/src/main/java/org/dspace/content/dao/impl/ItemForMetadataEnhancementUpdateDAOImpl.java index db8b988f94af..8ffe2d5de534 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/impl/ItemForMetadataEnhancementUpdateDAOImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/impl/ItemForMetadataEnhancementUpdateDAOImpl.java @@ -88,14 +88,14 @@ public int saveAffectedItemsForUpdate(Context context, UUID uuid) { + " SELECT dspace_object_id FROM metadatavalue " + " WHERE metadata_field_id IN" + " ( SELECT metadata_field_id FROM metadatafieldregistry " + " WHERE metadata_schema_id = :schema AND element = 'virtualsource')" - + " AND substring(text_value,1,36) = :uuid)"; + + " AND SUBSTRING(text_value,1,36) = :uuid)"; String sqlInsert = "INSERT INTO itemupdate_metadata_enhancement (uuid, date_queued)" + " SELECT DISTINCT dspace_object_id, CURRENT_TIMESTAMP FROM metadatavalue " + " WHERE metadata_field_id IN" + " ( SELECT metadata_field_id FROM metadatafieldregistry " + " WHERE metadata_schema_id = :schema AND element = 'virtualsource')" - + " AND substring(text_value,1,36) = :uuid " + + " AND SUBSTRING(text_value,1,36) = :uuid " + " AND dspace_object_id NOT IN (" + " SELECT uuid" + " FROM itemupdate_metadata_enhancement" diff --git a/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/h2/V7.6_2024.04.09__create_idx_optimize_item_poller.sql b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/h2/V7.6_2024.04.09__create_idx_optimize_item_poller.sql index a3dbfb01d025..cda4d33018d4 100644 --- a/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/h2/V7.6_2024.04.09__create_idx_optimize_item_poller.sql +++ b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/h2/V7.6_2024.04.09__create_idx_optimize_item_poller.sql @@ -10,5 +10,7 @@ -- Create INDEXES to optimize exact query over the metadatavalue ----------------------------------------------------------------------------------- -CREATE INDEX idx_text_value_hash ON metadatavalue (substring(text_value,1,36)); +-- we cannot create the idx related to the text_value substring in H2 as index on +-- expression are not supported, see https://github.com/h2database/h2database/issues/3535 +-- CREATE INDEX idx_text_value_hash ON metadatavalue (SUBSTRING(text_value,1,36)); CREATE INDEX idx_authority_hash ON metadatavalue (authority); \ No newline at end of file