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

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

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 2.13.0
    • GridFS
    • None
    • Linux

    Description

      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 .

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: