performance - MongoDB Index definition strategy -
i have mongodb-based database 100k 500k text documents inside , collection keeps growing. system should support queries different fields of documents, e.g. title, category, importance etc.
the system near real-time system, got new documents every 5-10 minutes.
my question:
idea, in order boost queries' performance, define separate index each frequently queried field (field types: small text, numeric, date) of document? or there best practices queries' performance boosting in mongodb?
you should use/make indexes depending on result trying find. it's idea have different indexes different field trying find @ different times.
but keep in mind indexes occupies ram. more make indexes more use ram. consider ordering of index while making better search.
when developing indexing strategy should have deep understanding of application’s queries. before build indexes, map out types of queries run can build indexes reference fields. indexes come performance cost, more worth cost frequent queries on large data set. consider relative frequency of each query in application , whether query justifies index.
the best overall strategy designing indexes profile variety of index configurations data sets similar ones you’ll running in production see configurations perform best.inspect current indexes created collections ensure supporting current , planned queries. if index no longer used, drop index.
some of strategies choose while creating:
create indexes support queries index supports query when index contains fields scanned query. creating indexes supports queries results in increased query performance.
use indexes sort query results support efficient queries, use strategies here when specify sequential order , sort order of index fields.
ensure indexes fit in ram when index fits in ram, system can avoid reading index disk , fastest processing.
create queries ensure selectivity selectivity ability of query narrow results using index. selectivity allows mongodb use index larger portion of work associated fulfilling query.
Comments
Post a Comment