『 读书笔记 』 50 Tips and Tricks for MongoDB Developers
原文链接 https://litaotao.github.io/50-tips-and-tricks-for-mongodb-developer
注:以下为加速网络访问所做的原文缓存,经过重新格式化,可能存在格式方面的问题,或偶有遗漏信息,请以原文为准。
写在前面
book 开头的文章都是记录我个人的读书记录的,里面分情况会记录下面这些东西:目录,读书感想,技术分享和推荐等。如果只是写下目录,那大多是留给自己以后看的。我不会把书长篇大论地翻译成中文,只会写下能对我个人以后真正有用的东西。 这是一本讲mongodb实践的经验书籍,就66页,除去前面目录什么的,也就50来页,对我个人还是挺有用的,所以我写下其目录,供以后复习时用。没必要写什么读书笔记,毕竟大脑才是最好用的u盘。
目录
- Duplicate data for speed, reference data for integrity
- Normalize if you need to future-proof
- data
- Try to fetech data in a single query
- Embed dependent fields
- Embed "point-in-time" data
- Do not embed fields that have unbound growth
- Pre-populate anything you can
- Preallocate space, whenever possible
- Store embedded information in arrays for anonymous access
- Desigin documents to be self-sufficient
- Prefer $-operators to JavaScript
- Compute aggregations as you go
- Write code to handle data integrity issues
- Use the correct types
- Override _id when you have your own simple, unique id
- Avoid using a document for _id
- Do not use database references
- Don't use GridFS for small binary data
- Handle "seamless" failover
- Handle replica set failure and failover
- Minimize disk access
- Use indexes to do more with less memory
- Don't always use an index
- Create indexes that cover your queries
- Use compound indexes to make multiple queries fast
- Create hierarchical documents for faster scans
- AND-queries should match as little as possible as fast as possible
- OR-queries should match as much as possible as soon as possible
- Write to the journal for single server, replicas for multiserver
- Always use replication, journaling, or both
- Do not depend on repair to recover data
- Understand getlasterror
- Always use safe writes in development
- Use w with replication
- Always use wtimeout with w
- Don's use fsync on every write
- Start up normally after a crash
- Take instant-in-time backups of durable servers
- Manually clean up your chunks collections
- Compact database with repair
- Don't change the number of votes for members of a replic set
- Replica sets can be reconfigured without a master up
- --shardsvr and --configsvr aren't required
- Only use --notablescan in development
- Learn some JavaScript
- Manage all of your servers and databases from one shell
- Get "help" for any function
- Create startup files
- Add your own functions
- Use a single connection to read your own writes