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

Drive counts fs.chunks and fs.files every time when new GridFS

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.13.0
    • Component/s: GridFS
    • None
    • Environment:
      Linux

      It counts on fs.files and fs.chunks every time to build index on collections when new a GridFS object.

      Source code in com.mongodb.gridfs.GirdFS :

      // ensure standard indexes as long as collections are small
      try {
      if (_filesCollection.count() < 1000)

      { _filesCollection.ensureIndex( BasicDBObjectBuilder.start().add( "filename" , 1 ).add( "uploadDate" , 1 ).get() ); }

      if (_chunkCollection.count() < 1000)

      { _chunkCollection.ensureIndex( BasicDBObjectBuilder.start().add( "files_id" , 1 ).add( "n" , 1 ).get() , BasicDBObjectBuilder.start().add( "unique" , true ).get() ); }

      } catch (MongoException e)

      { LOGGER.info(String.format("Unable to ensure indices on GridFS collections in database %s", db.getName())); }

      I think it should check on the index exists ,not the row counts .

            Assignee:
            Unassigned Unassigned
            Reporter:
            carl.dong@windfindtech.com carl dong
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: