bookstorebooks inside bookstorebookstore databasebooks collection using a hashed shard key on the ISBN fieldISBN, title, and authorbookstorebooks inside bookstorebookstore databasebooks collection using a hashed shard key on the ISBN fieldISBN, title, and authorbookstore database and books collectionbookstore and a collection called books. Insert these exact documents into books: { ISBN: "978-0143127741", title: "Sapiens", author: "Yuval Noah Harari" }, { ISBN: "978-0385543767", title: "The Midnight Library", author: "Matt Haig" }, { ISBN: "978-0062316097", title: "The Alchemist", author: "Paulo Coelho" }.Use use bookstore to switch to the database. Use db.books.insertMany([...]) to add the documents.
bookstore databasebookstore database by running sh.enableSharding("bookstore").Use the sh.enableSharding() command with the database name.
books collection using a hashed shard key on ISBNbooks collection in the bookstore database using a hashed shard key on the ISBN field by running sh.shardCollection("bookstore.books", { ISBN: "hashed" }).Use sh.shardCollection() with the full collection name and specify the shard key as { ISBN: "hashed" }.
books collection with these exact values: { ISBN: "978-1501128035", title: "The Power of Habit", author: "Charles Duhigg" }.Use db.books.insertOne() with the exact document.
What is the main purpose of hash-based sharding in MongoDB?
Which of the following is the correct way to create a hashed shard key on the field userId in MongoDB?
sh.shardCollection("mydb.users", { ??? })Given a collection sharded by { userId: "hashed" }, which shard will store the document { userId: 42, name: "Alice" }?
Assume the hash function maps 42 to a hash value that falls into shard 2's range.
Consider this command to shard a collection:
sh.shardCollection("mydb.orders", "orderId: hashed")After running this, you get an error: "Error: shard key must be an object". What is the likely cause?
You want to shard a collection by email using hash-based sharding. However, you notice some shards have much more data than others. What could be a reason for this uneven distribution?
Pass the test and this pattern moves unknown