Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace usage of deprecated collection.count() with collection.countDocuments() [DATAMONGO-2059] #2925

spring-projects-issues opened this issue Aug 16, 2018 · 3 comments


Copy link

@spring-projects-issues spring-projects-issues commented Aug 16, 2018

Christoph Strobl opened DATAMONGO-2059 and commented

        .near(new Point(1, 0)))

fails with

error 2 (BadValue): $match does not support $geoNear, $near, and $nearSphere

we need to switch over to $geoWithin using $center

Reference URL:

Issue Links:

  • DATAMONGO-2192 Improve count() and countDocuments() mapping documentation and/or method availability

Referenced from: pull request #604

Copy link

@spring-projects-issues spring-projects-issues commented Aug 17, 2018

Mark Paluch commented

This is a known issue and we spiked on possible ways how to address MongoDB's behavior. Right now we're recommending to use geoWithin query operators (in criteria Query and repository query methods) when using Client Sessions and count-based queries

Copy link

@spring-projects-issues spring-projects-issues commented Mar 5, 2020

Doron Levari commented

We are getting KILLED by Mongo 4.0 doing count instead of countDocuments. We are already using 2.2.4. Any chance this can backport to 2.2.X?

Any workaround you may think of until 3.0 gets out? When is that planned?


See below a slow q log from Mongo, stupid count, there are 7 docs in the "device" collection... 7!!! (2 are configState: "NOT_SYNCED") and the count takes 97 seconds because of "schemaLock"... Please help!!

2020-03-05T14:14:48.589+0000 I COMMAND  [conn2198692] command XYZ.device command: count { count: "device", query: { configState: "NOT_SYNCED" }, $db: "XYZ", $clusterTime: { clusterTime: Timestamp(1583417583, 16), signature: { hash: BinData(0, 09E81DF60CD75D49362F7838374CE05FF94C82A6), keyId: 6753496676054335795 } }, lsid: { id: UUID("25508109-bce4-4554-af76-5fd3cc099052") } } planSummary: COUNT_SCAN { configState: 1 } keysExamined:1 docsExamined:0 numYields:0 reslen:170 locks:{ Global: { acquireCount: { r: 1 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { r: 1 } } } storage:{ timeWaitingMicros: { handleLock: 14705, schemaLock: 97085560 } } protocol:op_msg 97101ms


Copy link

@spring-projects-issues spring-projects-issues commented Mar 5, 2020

Christoph Strobl commented

Please find planned release dates in our wiki or the Spring Calendar.
A backport is rather unlikely. We need to see if we can do something about this for the 2.2.x line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants