spring-projects / spring-projects/spring-data-mongodb
Debug line for count() call in ReactiveMongoTemplate happens twice
@marcingrzejszczak is already working on this.
Since Oct 2, 2024.
- Dominant language
- Java
- Stars
- 1.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
I was noticing that the exact same debug statement is duplicated in
https://github.com/spring-projects/spring-data-mongodb/blob/main/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoTemplate.java#L1153
and on the underlying method call at
https://github.com/spring-projects/spring-data-mongodb/blob/main/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoTemplate.java#L1172
So if we have debug logging turned on, it looked like perhaps the [expensive] count query is being done twice, but really it only happens once. I'd suggest changing or removing the debug statement on line 1153 in favor of 1172.
As it is today, the output (with debug turned on of course) looks like this, though count is only executed once:
2023-03-08T13:07:50.389-07:00 DEBUG 21153 --- [ctor-http-nio-3] o.s.d.m.core.ReactiveMongoTemplate : Executing count: { "tenantId" : "effa4be0-573d-11e9-8647-d663bd873d93", "$or" : [{ "language" : { "$regularExpression" : { "pattern" : "en", "options" : "i"}}}, { "language" : { "$regularExpression" : { "pattern" : "fr", "options" : "i"}}}]} in collection: session
2023-03-08T13:07:50.390-07:00 DEBUG 21153 --- [ctor-http-nio-3] o.s.d.m.core.ReactiveMongoTemplate : Executing count: { "tenantId" : "effa4be0-573d-11e9-8647-d663bd873d93", "$or" : [{ "language" : { "$regularExpression" : { "pattern" : "en", "options" : "i"}}}, { "language" : { "$regularExpression" : { "pattern" : "fr", "options" : "i"}}}]} in collection: session
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.