[JAVA-1938] Drive counts fs.chunks and fs.files every time when new GridFS Created: 27/Aug/15  Updated: 27/Jan/16  Resolved: 02/Sep/15

Status: Closed
Project: Java Driver
Component/s: GridFS
Affects Version/s: 2.13.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: carl dong Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux


Issue Links:
Duplicate
duplicates JAVA-389 Make GridFS index check/ensure less c... Closed

 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 .



 Comments   
Comment by Ross Lawley [ 02/Sep/15 ]

Duplicate of JAVA-389

Comment by Ross Lawley [ 27/Aug/15 ]

Hi carl.dong@windfindtech.com,

Thanks for the ticket, this ensures that the index is only created if there is only a small amount of existing data. As ensureIndex checks for the index and creates it if necessary, if there was a lot of existing data then this could be expensive and blocking.

As part of the forthcoming 3.2 version of the driver we a new GridFS implementation is included, which follows the new specification and does as you suggest, checks the index exists rather than the counts.

Ross

Generated at Thu Feb 08 08:55:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.