MongoDB offers powerful features for advanced query and index optimization, enhancing database performance. Developers can utilize geospatial queries for location-based data, full-text search for fast text retrieval, TTL indexes for automated data expiration, and performance tuning techniques for scalability. This quiz explores these advanced concepts to boost your MongoDB expertise.
a) Compound Index
b) Geospatial Index
c) Text Index
d) TTL Index
a) $within
b) $geoWithin
c) $contains
d) $geoMatch
$near operator in geospatial queries is used to:a) Match documents by exact coordinates
b) Sort documents by distance from a point
c) Check if a field exists
d) Perform full-text search
a) Arrays of points
b) JSON strings
c) Binary objects
d) Tables
a) 2d Index
b) 2dsphere Index
c) Polygon Index
d) None of the above
a) Compound Index
b) Full-text Index
c) Text Index
d) Unique Index
a) db.collection.textSearch()
b) db.collection.search()
c) $text
d) $findText
$text operator requires which field to be included?a) $search
b) $index
c) $match
d) $contains
$language field specify in a text search query?a) The text encoding format
b) The natural language for stemming and tokenization
c) The character limit for the text
d) The index size
a) Using $sort
b) Using $meta
c) Using $rank
d) Using $priority
a) Archiving documents
b) Automatically deleting expired documents
c) Improving query performance
d) Optimizing storage
a) Numeric fields
b) String fields
c) Date fields
d) ObjectId fields
a) 1 second
b) 1 millisecond
c) 1 minute
d) 1 hour
a) By the _id field
b) Using a specific TTL field
c) Through a Unix timestamp field
d) Using the index creation command
a) The document is archived
b) The document is deleted automatically
c) An error is thrown
d) The index is dropped
explain() in MongoDB?a) To execute a query faster
b) To analyze query performance and execution plan
c) To create indexes
d) To delete unnecessary data
a) queryOptimizer
b) allowDiskUse
c) memoryLimit
d) maxQueryMem
a) By reducing the document size
b) By distributing data across multiple nodes
c) By compressing indexes
d) By archiving old data
a) Improves query performance for specific use cases
b) Reduces storage requirements
c) Slows down write operations
d) Prevents duplicate entries
a) Increasing index size
b) Using smaller document sizes
c) Reducing memory usage
d) Limiting the number of shards
a) Using db.performanceCheck()
b) Through MongoDB Compass or Monitoring Tools
c) By writing custom scripts
d) Through server logs
a) Using transactions
b) Using queries
c) By creating unique indexes
d) By sharding collections
a) CPU performance
b) Disk I/O and concurrency
c) Memory usage
d) Backup speeds
a) mongo-analyze
b) profiler
c) mongotop
d) logParser
a) Reducing index usage
b) Indexing frequently queried fields
c) Analyzing slow queries
d) Using sharding for large datasets
| QNo | Answer |
|---|---|
| 1 | b) Geospatial Index |
| 2 | b) $geoWithin |
| 3 | b) Sort documents by distance from a point |
| 4 | a) Arrays of points |
| 5 | c) Polygon Index |
| 6 | c) Text Index |
| 7 | c) $text |
| 8 | a) $search |
| 9 | b) The natural language for stemming and tokenization |
| 10 | b) Using $meta |
| 11 | b) Automatically deleting expired documents |
| 12 | c) Date fields |
| 13 | c) 1 minute |
| 14 | c) Through a Unix timestamp field |
| 15 | b) The document is deleted automatically |
| 16 | b) To analyze query performance and execution plan |
| 17 | b) allowDiskUse |
| 18 | b) By distributing data across multiple nodes |
| 19 | a) Improves query performance for specific use cases |
| 20 | b) Using smaller document sizes |
| 21 | b) Through MongoDB Compass or Monitoring Tools |
| 22 | a) Using transactions |
| 23 | b) Disk I/O and concurrency |
| 24 | c) mongotop |
| 25 | a) Reducing index usage |
4o