ADD: individual and compound indexes
This commit is contained in:
@@ -42,5 +42,14 @@ const transactionSchema = new mongoose.Schema(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Add individual indexes for frequently queried fields
|
||||||
|
transactionSchema.index({ type: 1 })
|
||||||
|
transactionSchema.index({ status: 1 })
|
||||||
|
transactionSchema.index({ value: 1 })
|
||||||
|
|
||||||
|
// Add compound indexes for common query patterns in aggregation
|
||||||
|
transactionSchema.index({ belongingId: 1, status: 1 })
|
||||||
|
transactionSchema.index({ belongingId: 1, type: 1, status: 1 })
|
||||||
|
|
||||||
const Transaction = mongoose.model('Transaction', transactionSchema)
|
const Transaction = mongoose.model('Transaction', transactionSchema)
|
||||||
module.exports = Transaction
|
module.exports = Transaction
|
||||||
|
|||||||
Reference in New Issue
Block a user