title: Why does MongoDB show slower performance than MySQL?
body: <p>My system config : OSx RAM:-8GB ,2.5 Gz i5</p>
  
  <p>Both database table has  1 mill rows and same  data . I am executing  same aggregate query at both database.</p>
  
  <pre><code>db.temp.aggregate([ 
      { "$match": { ITEMTYPE: 'like' } },
      { "$group" : {_id :{ cust_id2: "$ActorID", cust_id: "$ITEMTYPE"}, numberofActorID : {"$sum" : 1}}},
      { "$sort": { numberofActorID: -1 } },
      { "$limit" : 5 }
  ]); 
  </code></pre>
  
  <p>I had created covering index </p>
  
  <pre><code>db.temp.ensureIndex( { "ITEMTYPE": 1, "ActorID": 1 } );
  </code></pre>
  
  <p>and selectivity of "like" is 80%</p>
  
  <p>Time Results are </p>
  
  <pre><code>sqlWithout    sqlWithIndex    mongoWithout       mongoWithIndex
  958                 644             3043                  4243
  </code></pre>
  
  <p>I didn't upgrade system parameter(not even sharding)  of MongoDB
  Please suggest me why  mongoDB is slow and how i can improve this problem.</p>
  
  <pre><code>{
      "stages" : [
          {
              "$cursor" : {
                  "query" : {
                      "ITEMTYPE" : "like"
                  },
                  "fields" : {
                      "ActorID" : 1,
                      "ITEMTYPE" : 1,
                      "_id" : 0
                  },
                  "plan" : {
                      "cursor" : "BtreeCursor ",
                      "isMultiKey" : false,
                      "scanAndOrder" : false,
                      "indexBounds" : {
                          "ITEMTYPE" : [
                              [
                                  "like",
                                  "like"
                              ]
                          ],
                          "ActorID" : [
                              [
                                  {
                                      "$minElement" : 1
                                  },
                                  {
                                      "$maxElement" : 1
                                  }
                              ]
                          ]
                      },
                      "allPlans" : [
                          {
                              "cursor" : "BtreeCursor ",
                              "isMultiKey" : false,
                              "scanAndOrder" : false,
                              "indexBounds" : {
                                  "ITEMTYPE" : [
                                      [
                                          "like",
                                          "like"
                                      ]
                                  ],
                                  "ActorID" : [
                                      [
                                          {
                                              "$minElement" : 1
                                          },
                                          {
                                              "$maxElement" : 1
                                          }
                                      ]
                                  ]
                              }
                          }
                      ]
                  }
              }
          },
          {
              "$group" : {
                  "_id" : {
                      "cust_id2" : "$ActorID",
                      "cust_id" : "$ITEMTYPE"
                  },
                  "numberofActorID" : {
                      "$sum" : {
                          "$const" : 1
                      }
                  }
              }
          },
          {
              "$sort" : {
                  "sortKey" : {
                      "numberofActorID" : -1
                  },
                  "limit" : NumberLong(5)
              }
          }
      ],
      "ok" : 1
  }
  </code></pre>
  
  <p>Structure of JSON </p>
  
  <pre><code>{ "_id" : ObjectId("5492ba51ff16cd9391a2c02d"), "POSTDBID" : 231041, "ITEMID" : 231041, "ITEMTYPE" : "post", "ITEMCREATIONDATE" : ISODate("2009-02-28T20:37:02Z"), "POSVal" : 0.327282, "NEGVal" : 0.315738, "NEUVal" : 0.356981, "LabelSentiment" : "Neutral", "ActorID" : NumberLong(1179444542), "QuarterLabel" : "2009-1\r", "rowid" : 2 }
  </code></pre>