Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • MongoDB Query Plan & Optimization

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 733
    Comment on it

    Indexes improve the efficiency of read operations by reducing the amount of data that query operations need to process. Create index for a collection : The index can be defined in schema of collection. Consider the following collection Accounts:

    AccountsSchema = new Schema({
      name: String,
      email: String,
      Contact: String,
      Gender: String,
      Age: Number
    });
    

    Create the index for the above collection

    AccountsSchema.index({ name: 1, email: 1});
    

    It will create index of all records for the collection Accounts that will help to improve query process when selecting using find() or findOne().

    To check MongoDB applied an index filter for a query shape, Use the cursor.explain() method and check the indexFilterSet field.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: