Skip to main content
Filter by
Sorted by
Tagged with
Advice
0 votes
2 replies
38 views

In MongoDB 7.0 when I run db.getCollection("NoSuchCollection").createIndex({ Whatever: 1 }); and the collection "NoSuchCollection" does not exist it is automatically created (and ...
EM0's user avatar
  • 6,605
1 vote
1 answer
61 views

I'm working with MongoDB transactions (Node.js, replica set). Inside a transaction, I update a document in a way that changes the value of a field that is covered by an index. Later in the same ...
Bear Bile Farming is Torture's user avatar
0 votes
2 answers
77 views

I have a MongoDB collection with documents containing an array of subdocuments. For example: { "_id": 1, "addresses": [ { "city": "New York", "...
Bear Bile Farming is Torture's user avatar
1 vote
2 answers
76 views

I am a new developer working with MongoDb Atlas, I am currently working on text searches over a collection with news texts. In this phase I am building the pipelines for those searches, so working ...
user2784897's user avatar
-2 votes
1 answer
98 views

I’m working with a MongoDB compound index like this: db.users.createIndex({ gender: 1, city: 1, age: 1 }) Suppose city has only a few possible values, e.g., "Chicago", "LA", "...
Bear Bile Farming is Torture's user avatar
-3 votes
1 answer
102 views

https://mongoplayground.net/p/2CHyeuaG0y0 db.test.aggregate([ { $match: { $or: [ { cheese: { "$exists": true } }, { ...
Bear Bile Farming is Torture's user avatar
0 votes
1 answer
95 views

I’m working with a collection where documents contain an array of subdocuments, for example: { "_id": 1, "tasks": [ { "priority": 2, "dueDate": "...
Bear Bile Farming is Torture's user avatar
-1 votes
1 answer
75 views

I have a users collection with a compound index: db.users.createIndex({ bin: 1, gender: 1, age: 1, location: 1, // ... other fields }); When I query like this: db.users.find({ bin: X, ...
Bear Bile Farming is Torture's user avatar
0 votes
1 answer
58 views

I am working with MongoDB and have a compound index on a collection, e.g., { a: 1, b: 1 }. I want to understand the performance implications when updating documents with respect to the fields in this ...
Bear Bile Farming is Torture's user avatar
-2 votes
1 answer
85 views

index: { "name": "tar", "key": { "tar.a": 1, "tar.b": 1 } tar is an array of subdocuments. query: ...
Bear Bile Farming is Torture's user avatar
-5 votes
1 answer
78 views

Given a aggregation pipeline like this, in which I use a $match with { $exists: false } on a indexed field: db.collection.aggregate([ { $match: { myField: { $exists: false } } } ]) ...
Bear Bile Farming is Torture's user avatar
0 votes
1 answer
260 views

I have a MongoDB collection items with the following indexes: db.items.createIndexes([{ team: 1, a: 1 }, { team: 1, b: 1 }]) I inserted some test data like this: db.items.insertMany([ { team: 1, a: &...
monday's user avatar
  • 1
0 votes
1 answer
63 views

I have a MongoDB collection and the following query: { isActive: true, managerId: null, clientId: { $ne: null } } I would like to optimize this query by creating an index. It looks like partial ...
Slava Fomin II's user avatar
0 votes
0 answers
70 views

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
-1 votes
1 answer
84 views

A TTL index is applied to a mongodb collection. It is instructed to delete documents after expiration if A = true. A document of this collection is currently locked inside a long running transaction. ...
Bear Bile Farming is Torture's user avatar
0 votes
0 answers
38 views

Index not getting applied while $lookup (Customers lookup in my query, _id index is not getting applied) for one of my query but for other query it’s getting applied. Below is the plan details which ...
user1952461's user avatar
0 votes
1 answer
75 views

I would like to know if there is a difference between these two types of index My goal is to create a composite index in the search for these two keys collection.Indexes.CreateOne( new ...
Vinicius Teixeira's user avatar
-2 votes
2 answers
191 views

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
2 votes
0 answers
43 views

I just "solved" a major performance issue in a Meteor.js application I maintain, but what I did seems completely counter intuitive. My guess is that my confusion has to do with my lack of ...
Eric Mittler's user avatar
0 votes
0 answers
37 views

Suppose I have a timeseries mongodb collections, similar to the one proposed in the official website, with a structure that might look like: [ { "timestamp": 1, "...
roschach's user avatar
  • 9,646
0 votes
1 answer
230 views

I have an index on the createdAt date field. I have an aggregation with this $match stage as the first stage: { "$expr" : { "$gte" : [ "$createdAt&...
link64's user avatar
  • 1,966
0 votes
2 answers
176 views

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
48 views

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
3 votes
0 answers
65 views

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
99 views

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
24 views

The following error: "The sort operation used more than the maximum 33554432 bytes of RAM." I have a find() that returns more than 9,000 records and I need to sort them by a nested field ...
GabrielCard's user avatar
-1 votes
2 answers
117 views

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
1 answer
377 views

I am planning to include indexes to make my mongodb queries faster, currently working on Springboot. I have variables userType and creationStamp (date and time in epoch milli while saving the document ...
zozo's user avatar
  • 1
0 votes
0 answers
49 views

I have a document with the following structure { "_id": 1, "list":[ { "_id": { "$oid": "64e4e7dcb7affd390938c40c" }, ...
Dani Ali's user avatar
0 votes
1 answer
608 views

I am deciding whether to auto delete expired documents via the TTL index or to have a background process that checks every 24 hours. I have read that the TTL index will check every x milliseconds, etc....
Bear Bile Farming is Torture's user avatar
-1 votes
1 answer
79 views

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
48 views

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
45 views

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
452 views

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
1 vote
1 answer
567 views

Consider a collection of approximately 1 mln. documents having the following schema: { _id: ObjectId(), Title: "", Description: "", Scheduling: { From: ...
Roberto Montalti's user avatar
1 vote
2 answers
318 views

Does MongoDB createIndexes() method, support specifying individual options for each index set in the script. Something like this below, which is not working by the way. Ref - https://www.mongodb.com/...
CSK 4ever's user avatar
1 vote
2 answers
510 views

The following statement regarding range filter and sorting and the way the predicates had to be placed is confusing. "MongoDB cannot do an index sort on the results of a range filter. Place the ...
CSK 4ever's user avatar
0 votes
0 answers
86 views

MongoDB collection index size using new array field takes more size than expected. This is a multikey index with an array field as the preceding index column in a collection which already has ...
CSK 4ever's user avatar
1 vote
1 answer
120 views

I am investigating Cygnus for FIWARE Orion historical data persistence. Since Cygnus 3.0.0, indexes are created according to the data model when writing to MongoDB, but the order of the indexes ...
ctc-watanabe's user avatar
0 votes
0 answers
54 views

At what number of shards do sharded collections begin to have a negative impact on the performances of read queries? Hundreds? Thousands? what is the rule of thumb?
Bear Bile Farming is Torture's user avatar
0 votes
2 answers
56 views

The $lookup stage will return an array of subdocuments. But the only value that I am interested in from the result of the $lookup is the the _id value. So instead of an array of { _id: ObjectId() }, ...
Bear Bile Farming is Torture's user avatar
0 votes
0 answers
135 views

Schema of collection: { field_1: "number", field_2: "number", ... } I have a query that may reference field_n dynamically depending on certain conditions that are not ...
Bear Bile Farming is Torture's user avatar
0 votes
1 answer
37 views

If I sort based on a column that has missing values, the missing values will be on top if sort is ascending. How to ensure that missing values always get pushed to the bottom regardless of ascending ...
Bear Bile Farming is Torture's user avatar
-1 votes
1 answer
145 views

Assuming that there is no index, is there a significant performance difference between sorting based on just one field vs multiple fields? db.movies.aggregate([ { $sort: { likes: -1 } } { $limit: ...
Bear Bile Farming is Torture's user avatar
-3 votes
1 answer
153 views

The base collection has 100,000 documents. All of which will be run through a $lookup stage. The collection that will be looked up in is empty. This query takes 30 seconds. When I remove the $lookup ...
Bear Bile Farming is Torture's user avatar
-1 votes
1 answer
45 views

Consider the case where $limit comes immediately after $sort: db.col.aggregate([ { $match: { } }, { $sort: { } }, { $limit: 10 } ]) I would assume that in the query above, the $sort stage would ...
Bear Bile Farming is Torture's user avatar
-1 votes
1 answer
45 views

Schema: { A: [ { name: "string", age: "integer" }, { name: "string", age: "integer" }, { name: "string", age: "integer" }, ...
Bear Bile Farming is Torture's user avatar
0 votes
0 answers
23 views

This is a query of my APP that returns a list of users. After the $match stage, some fields will be modified and a $lookup stage is involved to find and remove blocked users. However, the distance ...
Bear Bile Farming is Torture's user avatar
2 votes
0 answers
44 views

I have two collection named as users and user_data, users is a primary collection and the user_data is a secondary collection. I have perform an aggregate query for retrieving millions of data but ...
Gaurav Chandel's user avatar
-1 votes
0 answers
49 views

I have two collections mainCol and joinedCol from which using joins i am fetching around millions of records and the db query is taking excessive time, i want to use indexes on the fields of joined ...
Aadi Sharma's user avatar

1
2 3 4 5
9