`

8: Preallocate space, whenever possible

阅读更多

原文如下:

 

This is closely related to both “Tip #6: Do not embed fields that have unbound

growth” on page 7 and “Tip #7: Pre-populate anything you can” on page 8. This is an

optimization for once you know that your documents usually grow to a certain size,

but they start out at a smaller size. When you initially insert the document, add a

garbage field that contains a string the size that the document will (eventually) be, then

immediately unset that field:

    > collection.insert({"_id" : 123, /* other fields */, "garbage" : someLongString})

    > collection.update({"_id" : 123}, {"$unset" : {"garbage" : 1}})

This way, MongoDB will initially place the document somewhere that gives it enough

room to grow (Figure 1-3).



看下unset的定义

类似占位符之类的,可能mongoDB对于unset后的字段空间不会删除,只是做一下标记,这样这部分空间已经预先分出来了,这个空间就可以被重用
分享到:
评论

相关推荐

    mina-whenever

    gem 'mina-whenever' 然后执行: $ bundle 或将其自己安装为: $ gem install mina-whenever 用法 在deploy.rb require 'mina/whenever' task deploy: :environment do deploy do ... on :launch do invoke...

    elastic_whenever:管理ECS计划任务,例如“每时每刻”

    gem 'elastic_whenever' 然后执行: $ bundle 或将其自己安装为: $ gem install elastic_whenever 用法 您几乎可以像everyever一样使用它。 但是,请注意,您必须指定一个标识符。 $ elastic_whenever --...

    glm-master.zip

    GLM emulates GLSL's approach to vector/matrix operations whenever possible. To use GLM, include glm/glm.hpp. Example from GLM manual: #include int foo() { glm::vec4 Position = glm::vec4( glm::vec3...

    STemWin5.44.zip

    enabling Graphical User Interfaces (GUI) building up with any STM32, any LCD and any LCD controller, taking benefit from STM32 hardware accelerations, whenever possible. STemWin Library is a full ...

    A complete Guide to Webdesign (ebook) 2008 new.pdf

    however, whenever possible, I have tried to provide enough background information on these topics to give designers a level of familiarity with the terminology and technologies. The content in this ...

    Beginning WebGL for HTML5

    WebGL (Web-based Graphics Language) is a wonderful and exciting new...This book presents theory when necessary and examples whenever possible. You will get a good overview of what you can do with WebGL.

    C++ const用法及注意事项

    effective c++ 条款03讲到:Use const whenever possible 由此可见const 限定符对于c++的重要性。下面尽可能全面的总结const 的用法和技巧。主要资料来源于c++ primer,标题后的页码为c++ primer 中文版(第四版)的...

    LimitOS:物联网设备的Websocket控制

    LimitOS IoT设备的Websocket控制: : 。 客户端激活说明 要将LimitOS与Raspberry Pi一起使用,请参阅的激活文档... bundle exec whenever --update-crontab limitos --set environment=production --roles=app,web,db

    clucene源码

    1. Whenever possible the caller must create the object that is being filled. For example: IndexReader->getDocument(id, document); As opposed to the old method of document = IndexReader->getDocument(id...

    Designing and Developing Maintainable Products and Systems MIL-HDBK-470A.pdf

    Unlike previous handbooks which focused only on maintainability, this document provides ... Whenever possible, references are given in the text to documents having more detailed information on a topic

    whenever.js:对JavaScript的重新解释,每当esolang

    每当.js 适应和实施到JavaScript。 关于 与原始实现的最大区别在于,everyth.js使用函数声明而不是语句,并通过其名称字符串而不是语句号来引用它们。 这样,我们可以快速访问宿主Javascript的所有功能,包括声明...

    HTML 4 For Dummies, 5th Edition.pdf

    whenever possible. Besides plain talk about hypertext, (X)HTML, and the Web, we include lots of examples, plus tag-by-tag instructions to help you build your very own Web pages with minimum muss and ...

    C#编码规范,共享参考

    C#编码规范, 1. 避免将多个类放在一个文件里面。 2. 一个文件应该只有一...b) Use partial classes whenever possible to factor out the maintained portions. 8. 避免利用注释解释显而易见的代码。 ...... .....

    有效软件测试的50条建议

    Automate regression tests whenever possible Avoid sole reliance on capture/playback Conduct performance testing with production-sized databases Tailor usability tests to the intended audience ...

    whenever和wherever引导的两种状语从句.doc

    whenever和wherever引导的两种状语从句.doc

    SCIENTIFIC COMPUTING 计算方法

    including proper problem formulation and interpretation of results, but I advocate the use of professionally written mathematical software for obtaining solutions whenever possible. The book is aimed ...

    figmark:在React代码中导入Figma设计

    whenever只要要在本地更新设计,请运行此命令。 您还会注意到*.pc文件是从中编译React文件的。 要了解有关如何使用PC文件的更多信息,可以检出存储库。 就是这样! 此时,您应该已经生成了可以导入的React文件。 ...

    模式分类英文原版

    topics in pattern recognition, based whenever possible on fundamental principles. We believe that this provides the required foundation for solving problems in more specialized application areas such ...

    whenever:Node.js模块的require()延迟

    var whenever = require('whenever'); var modules = whenever('foo', __dirname); console.log(modules); // {} -> not loaded yet. modules.foo.hello(); // requires and then prints 'Hello world'; 您还可以...

    Http essential

    Http essential。http 协议简介、协议应用

Global site tag (gtag.js) - Google Analytics