Skip to content

Commit

Permalink
Merged in DSC-1640 (pull request DSpace#2026)
Browse files Browse the repository at this point in the history
CST-14516 Improve the performance of RelatedItemEnhancerUpdatePoller

Approved-by: Daniele Ninfo
  • Loading branch information
abollini authored and danieleninfo committed Apr 15, 2024
2 parents a759110 + 81381cf commit d926d83
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 text_value = :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 text_value = :uuid) "
+ " WHERE metadata_schema_id = :schema AND element = 'virtualsource')"
+ " AND substring(text_value,1,36) = :uuid "
+ " AND dspace_object_id NOT IN ("
+ " SELECT uuid"
+ " FROM itemupdate_metadata_enhancement"
Expand All @@ -113,8 +113,8 @@ public int saveAffectedItemsForUpdate(Context context, UUID uuid) {
+ " 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 text_value = :uuid) "
+ " WHERE metadata_schema_id = :schema AND element = 'virtualsource')"
+ " AND substring(text_value,1,36) = :uuid "
+ " ON CONFLICT (uuid) DO UPDATE"
+ " SET date_queued = EXCLUDED.date_queued";
NativeQuery<?> queryInsertOrUpdate = session.createNativeQuery(sqlInsertOrUpdate);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--
-- The contents of this file are subject to the license and copyright
-- detailed in the LICENSE and NOTICE files at the root of the source
-- tree and available online at
--
-- http://www.dspace.org/license/
--

-----------------------------------------------------------------------------------
-- Create INDEXES to optimize exact query over the metadatavalue
-----------------------------------------------------------------------------------

CREATE INDEX idx_text_value_hash ON metadatavalue (substring(text_value,1,36));
CREATE INDEX idx_authority_hash ON metadatavalue (authority);
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--
-- The contents of this file are subject to the license and copyright
-- detailed in the LICENSE and NOTICE files at the root of the source
-- tree and available online at
--
-- http://www.dspace.org/license/
--

-----------------------------------------------------------------------------------
-- Create INDEXES to optimize exact query over the metadatavalue
-----------------------------------------------------------------------------------

CREATE INDEX idx_text_value_hash ON metadatavalue (substring(text_value,1,36));
CREATE INDEX idx_authority_hash ON metadatavalue (authority);

0 comments on commit d926d83

Please sign in to comment.