How do you optimize performance in MongoDB?
- Indexing: Create appropriate indexes to optimize query performance.
- Sharding: Distribute large datasets across multiple servers.
- Caching: Cache frequently accessed data.
- Aggregation optimization: Use $match early in the aggregation pipeline.
- Avoid joins: MongoDB performs best when data is denormalized or embedded.
Database Security