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

Collscan on Browsing a Collection #1518

Open
Xeroxxx opened this issue Apr 21, 2024 · 4 comments
Open

Collscan on Browsing a Collection #1518

Xeroxxx opened this issue Apr 21, 2024 · 4 comments

Comments

@Xeroxxx
Copy link

Xeroxxx commented Apr 21, 2024

I've the problem that when I open a large collection (~10.000.000 Obj, 22kb Avg, 100GB).

I takes ages to load and I can see a COLLSCAN of _id in the logs.

mongo-1          | {"t":{"$date":"2024-04-20T23:47:40.771+00:00"},"s":"I",  "c":"COMMAND",  "id":51803,   "ctx":"conn26","msg":"Slow query","attr":{"type":"command","ns":"xxx.xxx",
"command":{"aggregate":"xxx","pipeline":[{"$match":{}},{"$group":{"_id":1,"n":{"$sum":1}}}],"cursor":{},"lsid":{"id":{"$uuid":"2b51c014-62f7-49d0-8279-979a8dfa868d"}},"$db":"poedata"},
"planSummary":"COLLSCAN","planningTimeMicros":166,"keysExamined":0,"docsExamined":9343804,"fromPlanCache":true,"cursorExhausted":true,"numYields":47869,"nreturned":1,"queryHash":"366C3F12","planCacheKey":"58CF6002","queryFramework":"sbe","reslen":128,"locks":{"FeatureCompatibilityVersion":{"acquireCount":{"r":47870}},"Global":{"acquireCount":{"r":47870}}},"storage":{"data":{"bytesRead":215941107656,"timeReadingMicros":641289510},"timeWaitingMicros":{"cache":588}},"cpuNanos":351818832796,"remote":"172.18.0.3:46260","protocol":"op_msg","durationMillis":861631}}

The extracted query of mongo express is an aggregate on:

{"$match":{}},{"$group":{"_id":1,"n":{"$sum":1}}}

Replacing the match with for ex sort uses the _id index and then its fast.

Can anyone explain why the Index is not used for browsing a collection and why the index is not used for _id?

@xTudoS
Copy link
Contributor

xTudoS commented Apr 27, 2024

Are you using the master version or 1.0.2 ?

@Xeroxxx
Copy link
Author

Xeroxxx commented Apr 27, 2024

Are you using the master version or 1.0.2 ?

I'm using latest docker image: https://hub.docker.com/_/mongo-express

Its tagged as 1.0.2-20

@xTudoS
Copy link
Contributor

xTudoS commented May 3, 2024

Are you using the master version or 1.0.2 ?

I'm using latest docker image: https://hub.docker.com/_/mongo-express

Its tagged as 1.0.2-20

try to build and use your own mongo-express image from master
use this repo to it: https://github.com/mongo-express/mongo-express-docker

official docker image is out-of-date

@Xeroxxx
Copy link
Author

Xeroxxx commented May 16, 2024

Master branch does not change the behavior.

I remember this was working late 2022 early 2023 or so. Thought is was update releated when I updated from mongo 5 to 6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants