Remove unnecessary type predicate (#1963)

* Remove unnecessary type predicate

* Add changelog
This commit is contained in:
James Agnew 2020-07-03 17:54:25 -04:00 committed by GitHub
parent e23e222f80
commit 290577ff3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View File

@ -0,0 +1,5 @@
---
type: perf
issue: 1963
title: "When performing a search in the JPA server using a chained search parameter, an unnecessary resource type predicate
was previously added to the generated SQL and has now been removed. This should improve performance on some queries."

View File

@ -354,7 +354,7 @@ class PredicateBuilderReference extends BasePredicateBuilder {
}
Predicate predicate = myCriteriaBuilder.or(toArray(theCodePredicates));
myQueryStack.addPredicate(predicate);
myQueryStack.addPredicateWithImplicitTypeSelection(predicate);
return predicate;
}

View File

@ -403,13 +403,16 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
List<String> ids;
SearchParameterMap map;
IBundleProvider results;
String searchSql;
map = new SearchParameterMap();
map.setLoadSynchronous(true);
map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject", "foo|bar").setChain("identifier"));
myCaptureQueriesListener.clear();
results = myEncounterDao.search(map);
myCaptureQueriesListener.logSelectQueriesForCurrentThread(0);
searchSql = myCaptureQueriesListener.logSelectQueriesForCurrentThread(0);
assertEquals(0, StringUtils.countMatches(searchSql, "RES_DELETED_AT"));
assertEquals(0, StringUtils.countMatches(searchSql, "RES_TYPE"));
ids = toUnqualifiedVersionlessIdValues(results);
assertThat(ids, hasItems(enc1Id, enc2Id));