Git Product home page Git Product logo

Comments (1)

eddiebrissow avatar eddiebrissow commented on August 14, 2024

(WIP) MONGODB INDEX RESEARCH

Indexes are special data structures that store a small portion of the collection's data set in an easy to traverse form. The index stores the value of a specific field or set of fields, ordered by the value of the field.

Default _id index

MongoDB creates a unique index on the _id field during the creation of a collection. The _id index prevents clients from inserting two documents with the same value for the _id field. You cannot drop this index on the _id field.

Single Field

User-defined ascending/descending indexes on a single field of a document.

Compound Index

User-defined indexes on multiple fields, the order of the indexed fields has a strong impact on the effectiveness of a particular index for a given query.

More info:
Compound Indexes

Limitations

  • Order can have a strong impact on the query

Multikey Index

MongoDB uses multikey indexes to index the content stored in arrays. If you index a field that holds an array value, MongoDB creates separate index entries for every element of the array

More info:
Multikey Indexes

Limitations

  • Can increase the index size
  • Index can not contain multiple arrays

Geospacial Index

More info:

Create a 2d Index

Text indexes

MongoDB provides a text index type that supports searching for string content in a collection. These text indexes do not store language-specific stop words (e.g. "the", "a", "or") and stem the words in a collection to only store root words.

More info:
Text Indexes

Limitations

  • Need more parameters in query, like the query score to retrieve meaningful data
  • Can increase the index size, due to big texts
  • More time to create indexes
  • Impacts write performance

Clustered Indexes

Starting in MongoDB 5.3, you can create a collection with a clustered index. Collections created with a clustered index are called clustered collections.

More info:
Clustered Collections,
clusteredIndex

Limitations

By default, if a secondary index exists on a clustered collection and the secondary index is usable by your query, the secondary index is selected instead of the clustered index.

WildCard Indexes

MongoDB supports creating indexes on a field or set of fields to support queries. Since MongoDB supports dynamic schemas, applications can query against fields whose names cannot be known in advance or are arbitrary.

To index the value of all fields in a document (excluding _id), specify "$**" as the index key:

db.collection.createIndex( { "$**" : 1 } )

More info:

Wildcard Indexes

Wildcard Index Restrictions

Limitations

  • Requires Version 4.2
  • Increases the size of the indexes for large databases
  • Can not shard widcard indexes

Partial Indexes

Partial indexes only index the documents in a collection that meet a specified filter expression. By indexing a subset of the documents in a collection, partial indexes have lower storage requirements and reduced performance costs for index creation and maintenance.

More info:
Partial Indexes

References

MongoDB's indexes documentation
How MongoDB Clustered Collection Can Boost Query Performance

from das.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.