Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-1551

DBCursor slowness

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 2.12.3
    • Fix Version/s: None
    • Component/s: Performance
    • Labels:
      None
    • Environment:
      RedHat server windows client

      Description

      We are using Spring Data with the MongoDB Java driver.
      We create an aggregation using AggregationOptions.OutputMode.CURSOR
      There are 2 fields in the projection on a collection with almost 800K documents.
      The aggregation does not use a sort or group; only a match and projection.
      The aggregation matches on a single String value that is indexed.
      The expected result set is all of the documents except 2 (over 700K).
      The DBCursor.next() method seems very slow. I've tried a smaller data set with OutputMode.INLINE and the next method is much faster.

      Here is the entire loop:
      while (cursor.hasNext()) {
      DBObject obj = cursor.next();
      logger.warn("count=" + count++);
      if (count % 10000 == 0)

      { logger.warn("count=" + count); }

      }

      Here are some timing from the logs:

      14 Nov 2014 14:44:56,328 WARN : TestDistributionFilter,207 - count=6133
      14 Nov 2014 14:44:56,418 WARN : TestDistributionFilter,207 - count=6134
      14 Nov 2014 14:44:56,508 WARN : TestDistributionFilter,207 - count=6135
      14 Nov 2014 14:44:56,597 WARN : TestDistributionFilter,207 - count=6136
      14 Nov 2014 14:44:56,686 WARN : TestDistributionFilter,207 - count=6137
      14 Nov 2014 14:44:56,776 WARN : TestDistributionFilter,207 - count=6138

      It seems odd that it is taking almost 100 milisecs to pull back a single record from the server. I've commented out the record logging but that did not help much.

      What can we do to speed it up?

      Thanks,

      gozer

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            michael.gozaloff@bankofamerica.com Mike Gozaloff
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: