402 questions
0
votes
2
answers
28
views
Can a partial multikey index in MongoDB index only certain subdocuments of an array?
I have a MongoDB collection with documents containing an array of subdocuments. For example:
{
"_id": 1,
"addresses": [
{ "city": "New York", "...
1
vote
2
answers
55
views
Mongodb/atlas search with punctuation signals
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 ...
-2
votes
1
answer
90
views
In MongoDB, is there a performance difference between $in covering all possible values vs leaving the field out in a compound index?
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", "...
-3
votes
1
answer
94
views
query that tries to match everything does not use the index [closed]
https://mongoplayground.net/p/2CHyeuaG0y0
db.test.aggregate([
{
$match: {
$or: [
{
cheese: {
"$exists": true
}
},
{
...
0
votes
1
answer
82
views
Does MongoDB update an index when array elements are only reordered?
I’m working with a collection where documents contain an array of subdocuments, for example:
{
"_id": 1,
"tasks": [
{ "priority": 2, "dueDate": "...
-1
votes
1
answer
66
views
Can MongoDB use a compound index to sort when filtering with $in?
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,
...
0
votes
1
answer
52
views
Performance impact of updating leading vs. trailing fields in a MongoDB compound index
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 ...
-2
votes
1
answer
80
views
can mongoDB use the full depth of a compound index on an array of subdocuments?
index:
{
"name": "tar",
"key": {
"tar.a": 1,
"tar.b": 1
}
tar is an array of subdocuments.
query:
...
-5
votes
1
answer
72
views
Can MongoDB use an index for $exists: false on an indexed field? [closed]
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 }
}
}
])
...
0
votes
1
answer
212
views
How to force MongoDB to always use specific indexes with $or clauses in
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: &...
0
votes
1
answer
55
views
MongoDB partial index optimization
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 ...
0
votes
0
answers
60
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.
...
-1
votes
1
answer
79
views
can a TTL index delete a document currently locked inside a long running transaction?
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. ...
0
votes
0
answers
37
views
Index not getting applied while $lookup for one of my query but for others it's getting applied. Not able to find out the mistake i am doing
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 ...
0
votes
1
answer
62
views
Difference in creating indexes in mongo db
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 ...