0
0
MongoDBquery~30 mins

Memory and storage engine basics (WiredTiger) in MongoDB - Mini Project: Build & Apply

Choose your learning style9 modes available
Memory and Storage Engine Basics with WiredTiger in MongoDB
📖 Scenario: You are managing a MongoDB database for a small online bookstore. You want to understand how to set up and configure the WiredTiger storage engine, which is the default in MongoDB, to optimize memory usage and storage performance.
🎯 Goal: Build a simple MongoDB configuration and query setup that demonstrates how to check and configure WiredTiger memory and storage settings.
📋 What You'll Learn
Create a MongoDB collection named books with sample documents.
Define a variable to hold the WiredTiger cache size configuration.
Write a query to retrieve all documents from the books collection.
Add a command to display the current WiredTiger cache usage statistics.
💡 Why This Matters
🌍 Real World
Understanding and configuring WiredTiger memory and storage settings helps optimize MongoDB performance for real applications like online bookstores.
💼 Career
Database administrators and developers need to know how to monitor and tune storage engines like WiredTiger to ensure efficient data storage and retrieval.
Progress0 / 4 steps
1
Create the books collection with sample documents
Create a MongoDB collection called books and insert these exact documents: { title: "The Great Gatsby", author: "F. Scott Fitzgerald", year: 1925 }, { title: "1984", author: "George Orwell", year: 1949 }, and { title: "To Kill a Mockingbird", author: "Harper Lee", year: 1960 }.
MongoDB
Need a hint?

Use db.books.insertMany() with an array of documents containing the exact fields and values.

2
Define WiredTiger cache size configuration variable
Create a variable called wiredTigerCacheSizeGB and set it to 1 to represent 1 gigabyte of WiredTiger cache size.
MongoDB
Need a hint?

Use const wiredTigerCacheSizeGB = 1 to set the cache size variable.

3
Query all documents from the books collection
Write a query using db.books.find() to retrieve all documents from the books collection.
MongoDB
Need a hint?

Use db.books.find() to get all documents.

4
Display WiredTiger cache usage statistics
Add the command db.serverStatus().wiredTiger.cache to display the current WiredTiger cache usage statistics.
MongoDB
Need a hint?

Use db.serverStatus().wiredTiger.cache to check cache stats.