Skip to content

Commit

Permalink
[perf] Improve document type detection performance
Browse files Browse the repository at this point in the history
Avoid converting potentially large documents as JSON objects by doing
a first test on the raw text.

Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
  • Loading branch information
pcdavid authored and sbegaudeau committed Aug 28, 2023
1 parent 74e9964 commit 58ec156
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.List;
import java.util.Optional;
import java.util.UUID;

import org.eclipse.sirius.components.annotations.Audited;
import org.eclipse.sirius.web.persistence.entities.DocumentEntity;
import org.springframework.data.jpa.repository.Query;
Expand Down Expand Up @@ -42,6 +43,7 @@ public interface IDocumentRepository extends PagingAndSortingRepository<Document
@Query(value = """
SELECT * FROM Document document
WHERE length(document.content) > 0
AND document.content LIKE ('%' || ?2 || '%')
AND document.content::::jsonb @> ('{ "ns": { "' || ?1 || '": "' || ?2 ||'" } }')::::jsonb
""", nativeQuery = true)
List<DocumentEntity> findAllByType(String name, String uri);
Expand Down

0 comments on commit 58ec156

Please sign in to comment.