diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java index 82ace12a07..2d71d36a64 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java @@ -105,6 +105,8 @@ public class AppProperties { private final List custom_provider_classes = new ArrayList<>(); private Boolean upliftedRefchains_enabled = false; + private List search_prefetch_thresholds = new ArrayList<>(); + public List getCustomInterceptorClasses() { return custom_interceptor_classes; @@ -644,6 +646,14 @@ public void setLanguage_search_parameter_enabled(Boolean language_search_paramet this.language_search_parameter_enabled = language_search_parameter_enabled; } + public List getSearch_prefetch_thresholds() { + return this.search_prefetch_thresholds; + } + + public void setSearch_prefetch_thresholds(List thePrefetchThresholds) { + this.search_prefetch_thresholds = thePrefetchThresholds; + } + public boolean getUpliftedRefchains_enabled() { return upliftedRefchains_enabled; } diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java b/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java index d12a2f2375..f046534db9 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java @@ -152,6 +152,10 @@ public JpaStorageSettings jpaStorageSettings(AppProperties appProperties) { jpaStorageSettings.setIndexOnUpliftedRefchains(appProperties.getUpliftedRefchains_enabled()); + if (!appProperties.getSearch_prefetch_thresholds().isEmpty()) { + jpaStorageSettings.setSearchPreFetchThresholds(appProperties.getSearch_prefetch_thresholds()); + } + Integer maxFetchSize = appProperties.getMax_page_size(); jpaStorageSettings.setFetchSizeDefaultMaximum(maxFetchSize); ourLog.info("Server configured to have a maximum fetch size of " diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 4fa3458aa1..8cb67003ee 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -236,7 +236,18 @@ hapi: search-coord-core-pool-size: 20 search-coord-max-pool-size: 100 search-coord-queue-capacity: 200 - + + # Search Prefetch Thresholds. + + # This setting sets the number of search results to prefetch. For example, if this list + # is set to [100, 1000, -1] then the server will initially load 100 results and not + # attempt to load more. If the user requests subsequent page(s) of results and goes + # past 100 results, the system will load the next 900 (up to the following threshold of 1000). + # The system will progressively work through these thresholds. + # A threshold of -1 means to load all results. Note that if the final threshold is a + # number other than -1, the system will never prefetch more than the given number. + search_prefetch_thresholds: 13,503,2003,-1 + # comma-separated package names, will be @ComponentScan'ed by Spring to allow for creating custom Spring beans #custom-bean-packages: