We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
We are using $sample 2 when getting captchas. This is causing slow queries on the nodes. We need to change this approach as follows:
$sample
Create an index on { datasetId: 1, solved: 1 }
Instead of $sample, use a random selection method to improve performance. For example:
Instead of sampling from the entire dataset, limit the query first:
db.captchas.aggregate([ { $match: { datasetId: "0xe666b35451f302b9fccfbe783b1de9a6a4420b840abed071931d68a9ccc1c21d", solved: true } }, { $limit: 1000 }, // Get a subset first { $sample: { size: 2 } }, // Then sample from that subset { $project: { datasetId: 1, datasetContentId: 1, captchaId: 1, captchaContentId: 1, items: 1, target: 1 } } ]);
This reduces the number of documents MongoDB has to scan.
The text was updated successfully, but these errors were encountered:
aggregate has no ordering so you don't need the random field
Sorry, something went wrong.
No branches or pull requests
We are using
$sample
2 when getting captchas. This is causing slow queries on the nodes. We need to change this approach as follows:Create an index on { datasetId: 1, solved: 1 }
Instead of $sample, use a random selection method to improve performance. For example:
Instead of sampling from the entire dataset, limit the query first:
This reduces the number of documents MongoDB has to scan.
The text was updated successfully, but these errors were encountered: