Comments (3)
刚测试:
81W文档,结构为:
{
_id: Number(0-100000)
jjc: Number(0-100000)
}
$set操作符
db.a.update({},{$set:{q: NumberInt(100)}},{multi:true});
初次时,耗时10秒。
当每个文档结构上都存在键值q
后,再次执行,耗时4秒。比find还快。find约为6秒。当然find要涉及到解析数据、传输数据。
$inc操作符
db.a.update({},{$inc:{jjc: -1}},{multi:true});
耗时17秒。大概涉及到解析数据、计算,比$set的直接覆盖要慢不少。
一般来说每日清零,就是$set
。性能还是很满意的
3月1日补充:
- update批量更新会消耗大量的CPU;另外iowait没测,但肯定会有。
- update默认不阻塞其他的读写。虽然整体性能会受影响,但应该不大。
- 4秒是mongodb完全没其他事情时的测试。
- $rename速度在12秒左右
db.a.update({},{"$rename":{"qq2":"qq3"}},{multi:true})
from bugs.
6月1日
关于$set不同类型的影响
测试在3.0.x的WT引擎下测试。分别在两台机器的SSD和HDD上进行了测试。
db.user.update({},{$set:{test:"一"}},{multi:true})
文档101万。大部分文档6字段,100字节。
表现:
- $set字符串长度1到100,插入耗时30秒
- $set数字1,耗时17秒
- 无论之前是否有test字段,$set字符串耗时都一样
- $set和旧值一样的字符串,插入耗时4秒
结论:
WT引擎下:
- $set字符串的长短对插入性能影响不大(前提是硬盘不是瓶颈)
- $set数字要比字符串快许多(当然他们大小也不一样,但感觉应该不是这个原因)
- 之前的预分配优化性能,这么看WT引擎下是没什么效果了。
- $set的值和旧值一样,会很快~(聊胜于无)
- 测试结果在SSD和HDD上没有区别,但CPU都彪满了。(MAC很奇怪,mongodb占200%了,总CPU量仍有很多空闲,猜测是系统做了保护)
猜测:
之所以慢下来,一方面可能是WT开启了测试(压缩方面用的默认配置)。
from bugs.
我选择第三种 貌似是最省事的,性能也很好。。
from bugs.
Related Issues (20)
- [收藏]A*的启发式算法
- 利用二进制操作降低保存进度的空间占用 HOT 1
- 计时器包装小计 HOT 2
- 多线程性能调优小记 HOT 1
- V8对象属性访问性能测试 HOT 1
- 不要对数组进行freeze或seal操作
- V8-JS性能调优小结 HOT 1
- 初识Async Functions和await
- HTML5游戏的资源内存管理 HOT 1
- 关于JS游戏服务端的新思考 HOT 2
- 貌似Node.js要引入worker了?
- ReactNative Macos环境搭建
- ReactNative Macos的性能测试
- ReactNative Macos首屏时间开销测量
- 跨平台类RN开发框架抽象思考 HOT 3
- Rust记录之模式匹配
- 订阅发布模式的优缺点
- VirtualizedList/FlatList工作原理及实现源码 HOT 1
- React Diff算法相关信息
- SectionList 和 FlatList 的具体差异在哪里
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bugs.