现在你已经感觉到索引的好处,但是让我提醒你它们不是所有查询都可以有大大的好处,试想,在Tip
#22上的例子中,提取几个记录我们返回一个集合90%的文档.如果我们在这种类型的查询上建立索引,然后通过索引树进行加载60G的索引到内存中,然后我们不得不根据索引的指针从集合中加载230GB的数据.我们最终加载230GB+60GB=290GB---
远远超过了我们不建立索引的大小.
因此,当你有一个你想返回数据总量的一部分时,索引在通常情况下是很有用的.一个好的经验是:,当你想返回一个集合中的约一半的数据时,它们就不那么有用了.
如果你在某个字段上建立一个索引,但是你做了次很大数据集查询那将会是非常低效的,你可以强制MongoDB不要使用索引通过排序通过{"natual":1}.
这个排序意味着 "返回的数据依靠你的磁盘" 这个可以强制使MongoDB不要使用索引:
-
>db.foo.find().sort({"$natural":1})
如果不是用索引进行查询,MongoDB会使用表来查询,这意味着将通过查询这个集合中的所有文档来寻找结果.
<写速度>
每次一个新增一个纪录,删除或者更新,必须更新受影响的每个索引.试想当你插入一个文档时,对于每个索引的值,MongoDB不得不查询新的文档在索引树的位置然后插入.对于删除,它必须查询树的条目然后从索引树中删除它.对于更新,你必须像插入一样添加索引,删除一样删除条目,不得不做这些如果一个值改动的话,因此,索引会增加相当多的开销.
分享到:
相关推荐
What's the best approach for developing an application with JavaScript? This book helps you answer that question with numerous JavaScript coding patterns and best practices. If you're an experienced ...
最优化理论的经典书籍。
an-introduction-to-optimization-4th-edition-solution-manual 为an introduction-to-optimization-4th-edition 的习题解答,高清英文完整版本
An Introduction to Optimization, 4th Edition
Optimizing subroutines in assembly language: An optimization guide for x86 platforms
本资源 为台湾清华大学祁忠勇教授在大陆教授的凸优化课程,已经去过好多高校了,暑期专业选修课程,需要较为扎实的数学基础,如线性代数,微积分,矩阵论,复变函数等等
It solves following optimization problem : min_X || Y-X||_1 + lambda ||Dh*X||_1 + lamdba ||Dv*X||_1 + mu ||X||_* X: Hyperspectral image Y: Compressive measurements Dh, Dv: Horizontal and vertical ...
最优化导论,英文版,2013版。作者:Edwin K. P. Chong Colorado State University,Stanislaw H. Zak Purdue University。
The use of optimization techniques is becoming essential to address rapidly increasing stringency of requirements for automotive systems. In particular, there is a growing interest in systematic ...
An overview of gradient descent optimization algorithms
An Introductionto Optimization最优化导论电子版讲义
%%## then fool around as always with the above thins %declare the parameters of the optimization max_iterations = 1000; no_of_particles = 50; dimensions = 1; delta_min = -0.003; delta_max = 0.003; ...
Ant colony optimization Introduction and recent trends
The purpose of the book is to give the reader a working knowledge of optimization theory and methods. To accomplish this goal, we include many examples that illustrate the theory and algorithms ...
介绍限制条件上如何求解优化问题。如lagrange multiplier.
simp3D论文An efficient 3D topology optimization code written inMatlab+ 程序+STL文件生成MATLAB程序
An Introduction to Optimization Second Edition
这是论文An Unconstrained Optimization Test Functions Collection里的测试函数,用Matlab写好了。
Title: Java EE 7 Performance Tuning and Optimization Author: Osama Oransa Length: 398 pages Edition: 1 Language: English Publisher: Packt Publishing Publication Date: 2014-06-25 ISBN-10: 178217642X ...
Image Optimization SDK控件 允许定制和在你的软件中使用我们产品Web Image Guru的功能。 <br> Image Optimization SDK控件 限制一台机器只能由一个开发者使用,为了创建基于客户的软件而不是为了多线程的...