Indexed capped collection performance degrades after there are thousands of entries

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Incomplete
    • Priority: Major - P3
    • None
    • Affects Version/s: 1.6.3
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Initially, two capped collections were created to implement "cache" feature.

      db.createCollection("purchase",

      {capped:true, size:10000000}

      )
      db.purchase.ensureIndex(

      {key:1, ts:-1}

      ,

      {background:true}

      );
      db.createCollection("refinance",

      {capped:true, size:10000000}

      )
      db.refinance.ensureIndex(

      {key:1, ts: -1}

      ,

      {background:true}

      );

      The lookup query is done via

      Date now = new Date();
      BasicDBObject dbQuery = new BasicDBObject();
      dbQuery.put(KEY_FIELD_NAME, requestSignature);
      dbQuery.put(TIMESTAMP_FIELD_NAME, new BasicDBObject("$gt",
      now.getTime() - query_offer_cache_expiration));

      cur = coll.find(dbQuery).addOption(
      Bytes.QUERYOPTION_SLAVEOK).sort(
      getMongoDBSortCriteria()).limit(1);

      We've three servers, each has 24 CPUs w/ total 48G.

      We see the query performance seems to degrade after we've thousands of documents. To get thing moving again, we dropped capped collections and recreated them. Now stats whos

      > db.refinance.stats()
      {
      "ns" : "mortgagecache.refinance",
      "count" : 591,
      "size" : 1235880,
      "avgObjSize" : 2091.167512690355,
      "storageSize" : 10000128,
      "numExtents" : 1,
      "nindexes" : 1,
      "lastExtentSize" : 10000128,
      "paddingFactor" : 1,
      "flags" : 0,
      "totalIndexSize" : 65536,
      "indexSizes" :

      { "key_1_ts_-1" : 65536 }

      ,
      "capped" : 1,
      "max" : 2147483647,
      "ok" : 1
      }

      Attaching the cache code

            Assignee:
            Unassigned
            Reporter:
            Joseph Wang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: