node.js - Mongo DB - What should I put to indexes? -


i have query .sort() , .select():

item.find({title: searchregexp}).lean().select('slug title poster').limit(50).sort('-_id') 

should put mongodb indexes:

  1. query fields { title: 1 }
  2. sort fields { _id: -1 })
  3. select fields { slug: 1, title: 1, poster: 1 }

or them together? { title: 1, _id: -1, slug: 1, title: 1, poster: 1 }


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -