我正在运行一个返回大量数据的查询。它查找 916 个文档,每个文档都有一个大数据字段(大约 5MB)。查询如下所示:
db.collection.find(
{'name': somename, 'currency': mycurrency,
'valuation_date': {'$in': [list_of_250_datetime_datetime]}
}.{'data_column: is set to true or false in the below test results}).limit(x)
我一直在尝试优化查询,发现大部分时间都花在加载(或传输)那个大数据项上,而不是在 5GB 的数据库中查找它。所以我假设查询已经过优化并且索引使用正确,这也得到了分析器的确认。
所以我认为从磁盘加载数据会花费大部分时间,但似乎当我使用内存存储引擎时,事情实际上变慢了。这怎么可能?我还能做些什么来加快速度?
在内存存储引擎中:
================ Starting test using mongodb://localhost:27018/ ================
Looking up 100 values excluding data column...
++++++++++ Query completed in 0.0130000114441 seconds ++++++++++
Looking up 100 values, full json with data...
++++++++++ Query completed in 2.85100007057 seconds ++++++++++
Looking up all values, excluding data column...
++++++++++ Query completed in 0.0999999046326 seconds for 916 items ++++++++++
Looking up all values, full json with data...
++++++++++ Query completed in 29.2250001431 seconds for 916 items ++++++++++
有线老虎:
================ Starting test using mongodb://localhost:27017/ ================
Looking up 100 values excluding mdo column...
++++++++++ Query completed in 0.0120000839233 seconds ++++++++++
Looking up 100 values, full json with data...
++++++++++ Query completed in 2.97799992561 seconds ++++++++++
Looking up all values, excluding data column...
++++++++++ Query completed in 0.0700001716614 seconds for 916 items ++++++++++
Looking up all values, full json with data...
++++++++++ Query completed in 23.8389999866 seconds for 916 items ++++++++++