Fix mongodb optimization section (#4629)

* Fix gtx-trans close sidepanel

* reset the package-lock.json file

* Fix: Performance Optimization

* Restore src/components/TopicDetail/TopicProgressButton.tsx file
pull/4631/head
Abdelrhman Kamal 1 year ago committed by GitHub
parent 7da244fe10
commit cc258b7612
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 68
      src/data/roadmaps/mongodb/content/105-performance-optimization/100-indexes.md
  2. 0
      src/data/roadmaps/mongodb/content/105-performance-optimization/101-atlas-search-indexes.md
  3. 0
      src/data/roadmaps/mongodb/content/105-performance-optimization/102-query-optimization.md
  4. 0
      src/data/roadmaps/mongodb/content/105-performance-optimization/index-types/100-expiring.md
  5. 0
      src/data/roadmaps/mongodb/content/105-performance-optimization/index-types/101-geospatial.md
  6. 0
      src/data/roadmaps/mongodb/content/105-performance-optimization/index-types/102-text.md
  7. 0
      src/data/roadmaps/mongodb/content/105-performance-optimization/index-types/103-compound.md
  8. 0
      src/data/roadmaps/mongodb/content/105-performance-optimization/index-types/104-single-field.md
  9. 0
      src/data/roadmaps/mongodb/content/105-performance-optimization/index-types/index.md
  10. 0
      src/data/roadmaps/mongodb/content/105-performance-optimization/index.md
  11. 18
      src/data/roadmaps/mongodb/mongodb.json

@ -0,0 +1,68 @@
# Creating Indexes
Indexes are a powerful feature in MongoDB that help improve the performance of read operations (queries) in your database. They work similarly to the indexes found in a book, where you can quickly locate specific information rather than scanning through the entire content. In this section, we will discuss the basics of MongoDB indexes and their usage.
## Overview of Indexes
Basically, an index in MongoDB is a data structure that holds a smaller version of the data in our documents, along with a reference to the original document. This smaller version is stored in an efficient manner, making it easier and faster to locate specific documents based on the indexed field(s).
Indexes can be created on one or more fields in a MongoDB collection. The default index that exists in every collection is the `_id` index, which ensures unique values for the `_id` field.
## Types of Indexes
There are several types of indexes in MongoDB, including:
- **Single Field Index:** Index based on a single field in the documents.
- **Compound Index:** Index based on multiple fields in the documents.
- **Multikey Index:** Index used when the indexed field contains an array of values.
- **Text Index:** Index used to support text search queries on string content.
- **2dsphere Index:** Index used to support geospatial queries on spherical data.
- **2d Index:** Index used to support geospatial queries on planar data.
It's important to choose the right type of index for the queries you will be running on your MongoDB collection.
## Creating Indexes
To create an index on a field or fields, you can use the `createIndex()` method. Here's an example of creating an index on the "username" field in the "users" collection:
```javascript
db.users.createIndex({ username: 1 });
```
The `1` indicates that the index uses ascending order on the "username" field. You can also create a descending order index using `-1` as the value.
For compound indexes, you can specify multiple fields like this:
```javascript
db.users.createIndex({ username: 1, email: 1 });
```
## Using Indexes
Once you have created an index on a field or fields, MongoDB will automatically use the appropriate index when you perform queries on the collection, optimizing the query execution.
To see which index is being used for a specific query, you can use the `explain()` method. For example, to see the index used for a query on the "username" field:
```javascript
db.users.find({ username: 'John' }).explain();
```
This will give you detailed information about the query execution, including the index used.
## Managing Indexes
To manage indexes, you can:
- List all the indexes in a collection: `db.COLLECTION_NAME.getIndexes()`.
- Remove an index: `db.COLLECTION_NAME.dropIndex(INDEX_NAME)`.
- Remove all indexes: `db.COLLECTION_NAME.dropIndexes()`.
## Limitations and Considerations
While indexes are an amazing tool, they can have some caveats:
- They consume storage space, so creating a large number of indexes may affect the storage capacity.
- They can slow down write operations, as indexes should be updated whenever write operations occur on the indexed fields.
- Indexes should be chosen wisely, considering the queries that will run on the collection.
In conclusion, MongoDB indexes are a vital aspect of optimizing query performance in your database. By understanding the different types of indexes and using them effectively, you can significantly improve the performance and efficiency of your MongoDB applications.

@ -493,7 +493,7 @@
"x": "899",
"y": "1850",
"properties": {
"controlName": "104-query-operators:index-types:single-field"
"controlName": "104-performance-optimization:index-types:single-field"
},
"children": {
"controls": {
@ -540,7 +540,7 @@
"x": "899",
"y": "1899",
"properties": {
"controlName": "103-query-operators:index-types:compound"
"controlName": "103-performance-optimization:index-types:compound"
},
"children": {
"controls": {
@ -587,7 +587,7 @@
"x": "899",
"y": "1948",
"properties": {
"controlName": "102-query-operators:index-types:text"
"controlName": "102-performance-optimization:index-types:text"
},
"children": {
"controls": {
@ -634,7 +634,7 @@
"x": "899",
"y": "1997",
"properties": {
"controlName": "101-query-operators:index-types:geospatial"
"controlName": "101-performance-optimization:index-types:geospatial"
},
"children": {
"controls": {
@ -681,7 +681,7 @@
"x": "899",
"y": "2045",
"properties": {
"controlName": "100-query-operators:index-types:expiring"
"controlName": "100-performance-optimization:index-types:expiring"
},
"children": {
"controls": {
@ -3740,7 +3740,7 @@
"x": "873",
"y": "1712",
"properties": {
"controlName": "105-query-operators"
"controlName": "105-performance-optimization"
},
"children": {
"controls": {
@ -3787,7 +3787,7 @@
"x": "886",
"y": "1795",
"properties": {
"controlName": "100-query-operators:indexes"
"controlName": "100-performance-optimization:indexes"
},
"children": {
"controls": {
@ -3834,7 +3834,7 @@
"x": "886",
"y": "2144",
"properties": {
"controlName": "101-query-operators:atlas-search-indexes"
"controlName": "101-performance-optimization:atlas-search-indexes"
},
"children": {
"controls": {
@ -3881,7 +3881,7 @@
"x": "886",
"y": "2194",
"properties": {
"controlName": "102-query-operators:query-optimization"
"controlName": "102-performance-optimization:query-optimization"
},
"children": {
"controls": {

Loading…
Cancel
Save