I am trying to select some document table columns and map them into new object instead of returning the document as a whole. I am quite concerned about the execution time of the below query as it takes around ~4200 ms to execute for ~35,000 entries. What would be best solution to decrease the execution time? Is 4 seconds good time for 35,000 entries?
@Query("SELECT DISTINCT new it.homepackage.models.document.DocumentGetReviewCommand(" +
"d.author.firstname, d.author.lastname, d.id, d.title, d.description, d.documentType.title, d.submissionDate)" +
" FROM Document d" +
" WHERE d.documentType IN :docTypes" +
" AND d.documentState = it.homepackage.enums.DocumentState.SUBMITTED" +
" AND :username <> d.author.username")
Page<DocumentGetReviewCommand> getDocumentsForReview(@Param(value = "username") String username,
Pageable pageable,
@Param(value = "docTypes") List<DocumentType> docTypes);