It performs a collection scan and reads a lot into the disk. I checked my application and couldn’t find this query in the source code.
So, is this aggregate query automatically executed by MongoDB, and what is its purpose? Is there any way to limit it because it is quite costly in terms of disk I/O?
May be you have some users, analyzing the schema with Compass. The presence of $sample:size:1000 might seems to match Compass remark that is printed when analyzing the schema.
This report is based on a sample of 1000 documents.
Are the queries spaced evenly over time? In principal an automated process would run the queries at a regular interval. A human will have more random interval.