mongodb - Efficient Retrieve of MongoDB items in a time range
问题描述
I am having a MongoDb collection of 70M items (200GB) and I am trying to get those in the range [from_date
, to_date
] using the command:
from_date = datetime.datetime(2015, 1, 14, 9, 46, 23)
to_date = datetime.datetime(2015, 1, 14, 9, 46, 24)
db.collection.find({"datetime": {"$gte": from_date, "$lte": to_date}})
However it takes a lot of time to retrieve those items even for a single query. Is there any more efficient way to do this?
解决方案
推荐阅读
- javascript - 在完整日历中的第一个日期未显示重复事件
- html - 表格中的 TH 是否允许使用标题?
- c - 使用带有联合的类型双关语的问题
- python - 如何使用 PyTorch 并行化 CNN 对图像的评估
- r - 将视觉元素(图标)添加到 ggpplot 标签
- ckeditor - ckeditor 自动在视觉上调整拖放图像的大小
- java - Azure Active Directory 的 Spring Security Oauth2
- sql - 在 SQL Server 中将 Varbinary 转换为 PDF
- dkim - 我可以只为一台特定的服务器配置 DKIM 吗?
- extjs - EXTJS:Ext.widget 和 Ext.create 有什么区别?