Skip to content

Commit ffd6456

Browse files
Updated documentation and test around query plan caching (Azure#28010)
1 parent cd3a8ec commit ffd6456

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Configs.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public static String getEnvironmentName() {
238238
}
239239

240240
public static boolean isQueryPlanCachingEnabled() {
241-
// Queryplan caching will be disabled by default
241+
// Queryplan caching is enabled by default
242242
return getJVMConfigAsBoolean(QUERYPLAN_CACHING_ENABLED, true);
243243
}
244244

sdk/cosmos/azure-spring-data-cosmos-test/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplatePartitionIT.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ public class CosmosTemplatePartitionIT {
9393
@Before
9494
public void setUp() throws ClassNotFoundException {
9595
if (cosmosTemplate == null) {
96-
// Enable Query plan caching for testing
97-
System.setProperty("COSMOS.QUERYPLAN_CACHING_ENABLED", "true");
96+
// Query plan caching is enabled by default
9897
CosmosAsyncClient client = CosmosFactory.createCosmosAsyncClient(cosmosClientBuilder);
9998
cosmosFactory = new CosmosFactory(client, TestConstants.DB_NAME);
10099
final CosmosMappingContext mappingContext = new CosmosMappingContext();

sdk/cosmos/azure-spring-data-cosmos-test/src/test/java/com/azure/spring/data/cosmos/core/ReactiveCosmosTemplatePartitionIT.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ public class ReactiveCosmosTemplatePartitionIT {
7979
@Before
8080
public void setUp() throws ClassNotFoundException {
8181
if (cosmosTemplate == null) {
82-
// Enable Query plan caching for testing
83-
System.setProperty("COSMOS.QUERYPLAN_CACHING_ENABLED", "true");
82+
// Query plan caching is enabled by default
8483
CosmosAsyncClient client = CosmosFactory.createCosmosAsyncClient(cosmosClientBuilder);
8584
cosmosFactory = new CosmosFactory(client, TestConstants.DB_NAME);
8685

sdk/cosmos/azure-spring-data-cosmos/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ public interface UserRepository extends CosmosRepository<User, String> {
307307
- `findByFirstName` method is custom query method, it will find items per firstName.
308308

309309
#### Query Plan Caching
310-
When query plan caching is enabled, custom query methods like `findByFirstName(String firstName)` where `firstName` is the partition key will result in lower query execution time. Query plan caching can be enabled by setting the `COSMOS.QUERYPLAN_CACHING_ENABLED` System property to 'true'. Currently, query plan caching is only supported for custom query methods targeting a single partition.
310+
Spring repository query APIs like `findByFirstName(String firstName)` where `firstName` is the partition or annotated queries containing partition key will result in lower query execution time because of query plan caching. Currently, query plan caching is only supported for query methods targeting a single partition.
311311

312312
#### QueryAnnotation : Using annotated queries in repositories
313313
Azure spring data cosmos supports specifying annotated queries in the repositories using `@Query`.

0 commit comments

Comments
 (0)