Skip to main content

All Questions

0 votes
0 answers
42 views

Using SQL LIKE operator in MongoDB indexes

I have a Flask app that queries my self-managed MongoDB. I've created an index on two fields so that I can perform a text search on it. The search is working fine, but it is only matching full words. ...
Mervin Hemaraju's user avatar
0 votes
0 answers
54 views

Mongodb sparse index vs partial index

I have a large collection of documents that have field C = null about 85% of the time and have queries looking for docs where C $ne: null. To speed those queries, I have considered a sparse and a ...
user17616601's user avatar
-2 votes
2 answers
93 views

Performance or index usage of the queries on an optional key in MongoDB

When an optional key in a collection is queried , performance varied with respect to the following two queries. Good response : When it queried with a specific value - a value other than null, it ...
Bear Bile Farming is Torture's user avatar
0 votes
2 answers
84 views

how to get mongodb to use a compound index where one of the fields is not involved?

compound index: { A: 1, B: 1, C: 1 } query: col.aggregate([ { $match: { B: "ssome_value", C: "some_other_value, } } ]) The query does not involve A, so the ...
Bear Bile Farming is Torture's user avatar
0 votes
1 answer
40 views

compound index and sort query involving a regex

please read comment and first answer. question is solved. https://mongoplayground.net/p/J1Hs5RKu39G I need help interpreting the explain output. I can see that the index is used. However, I am still ...
Bear Bile Farming is Torture's user avatar
0 votes
0 answers
31 views

will N $facet pipelines be equivalent to N concurrent API calls / queries? [duplicate]

I am facing the decision to either send 100 concurrent API calls / queries to mongoDB or to send 1 query with 100 $facet pipelines. Will they be more or less equivalent in terms of resources taken up?
Bear Bile Farming is Torture's user avatar
3 votes
0 answers
55 views

will each condition inside an $or of the $match stage be checked concurrently?

compound index { A: 1, timestamp: 1, } and { B: 1, timestamp: 1, } db.user.aggregate([ { $match: { $or: [ { A: "some_value" }, { B: "some_value" } ] } }, { ...
Bear Bile Farming is Torture's user avatar
-1 votes
1 answer
48 views

will mongodb use index to sort when $or used in $match?

compound index { A: 1, timestamp: 1, } and { B: 1, timestamp: 1, } db.user.aggregate([ { $match: { $or: [ { A: "some_value" }, { B: "some_value" } ] } }, { ...
Bear Bile Farming is Torture's user avatar
0 votes
0 answers
28 views

how to index a field that holds a subdocument?

schema: { A: { X: "string", Y: "string", Z: "string" } } Is it possible to index A and have this index used when querying for A.X, A.Y, or A.Z?
Bear Bile Farming is Torture's user avatar
-1 votes
2 answers
70 views

mongodb not using index unless field is specified in $match

compound index { A: 1, B: 1 } In this query, the compound index is not used: db.user.aggregate([ { $match: { B: { $gt: 100 } } }, { $sort: { A: 1 } }, { $limit: ...
Bear Bile Farming is Torture's user avatar
0 votes
0 answers
208 views

Slow query message on MongoDB ends up with a RAM overload

I'm running a MongoDB server on a VM, which has 4gb of ram, 2 vCPU and a SSD disk. The database is connected to an API, which is becoming more and more widely used, so requests to the database are ...
cypolo's user avatar
  • 37
-1 votes
1 answer
53 views

$limit in a scatter and gather query to a sharded collection

user.aggregate([ { $match: { age: { $gt: 18 }, city: { $in: ["chicago", "paris"] } } }, { $sort: { last_logged_in: -1 } }, { $limit: ...
Bear Bile Farming is Torture's user avatar
0 votes
1 answer
36 views

will this $sort and $limit query use the index or be a blocking in memory sort?

index: { last_logged_in: -1 } query: user.aggregate([ { $match: { age: { $gt: 18 }, city: { $in: ["chicago", "paris"] } } }, { $sort: { ...
Bear Bile Farming is Torture's user avatar
-2 votes
1 answer
41 views

The purpose of sharding in mongoDB [closed]

I have a collection that only holds 10 million documents, totaling 10 gigabytes. This may not seem like enough to necessitate sharding. But there is a query that takes 1000 seconds to complete on this ...
Bear Bile Farming is Torture's user avatar
0 votes
1 answer
239 views

unique index only if field exist

If There is a unique index on a field A, then there cannot be 2 documents where A doesn't exist. How do I specify that the uniqueness should only be enforced on documents where A actually exists?
Bear Bile Farming is Torture's user avatar

15 30 50 per page
1
2 3 4 5
11