Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Consequences of a COLLSCAN in MongoDB?

Tags:

mongodb

I understand what a COLLSCAN is in MongoDB query plan - there is no index available so Mongo must scan the entire collection.

Obviously this will cause longer execution times for the query in question, but what I'm wondering about is if it causes any other things to happen that could affect performance? Increased memory usage? Could it push other data that needs to be in memory out of memory while it's scanning the whole table?

I found mention of COLLSCAN on this MongoDB documentation page, but it doesn't go into much detail about what happens or possible consequences. Can anyone explain (or point me to a resource that does) what other problems could potentially occur do to a COLLSCAN?

like image 212
Abe Miessler Avatar asked Jun 13 '16 21:06

Abe Miessler


1 Answers

On busy systems this will affect performance, as data need to be read from disk, allocated in page (memory) - which at the could activate swapping process.

Depending on amount of system memory and disk performance - this will be not a case when it could be cached or reads will not be blocking other I/O operations.

If COLLSCAN occurs on application primary collection - other data will be freed or pushed to swap if no RAM available.

COLLSCAN could occur on indexed field during aggregation framework pipeline execution - when pipeline request cannot use indexes at execution phase.

like image 194
profesor79 Avatar answered Sep 24 '22 10:09

profesor79