小编Mik*_*e A的帖子

MongoDB 性能与 PostgreSQL 的 550 万行/文档对比

有人可以帮我比较这些查询并解释为什么 PostgreSQL 查询的执行时间不到 2000 毫秒,而 MongoDB 聚合查询需要将近 9000 毫秒,有时甚至高达 130K 毫秒吗?

PostgreSQL 9.3.2 on x86_64-apple-darwin, compiled by i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00), 64-bit
Run Code Online (Sandbox Code Playgroud)

PostgreSQL 查询

SELECT locomotive_id,
   SUM(date_trunc('second', datetime) - date_trunc('second', prevDatetime)) AS utilization_time

FROM bpkdmp 
WHERE datetime >= '2013-7-26 00:00:00.0000' 
AND   datetime <= '2013-7-26 23:59:59.9999'
GROUP BY locomotive_id
order by locomotive_id
Run Code Online (Sandbox Code Playgroud)

MongoDB 查询

db.bpkdmp.aggregate([
   {
      $match : {
          datetime : { $gte : new Date(2013,6,26, 0, 0, 0, 0), $lt : new …
Run Code Online (Sandbox Code Playgroud)

postgresql performance mongodb

12
推荐指数
1
解决办法
1万
查看次数

标签 统计

mongodb ×1

performance ×1

postgresql ×1