GridFS Index in MongoDB


GridFS Index
The unique and compound index used by GridFS on chunks collection for the files _id and n fields. _id field contains the _id of the chunk's "parent" document and the n filed contains the sequence number of the chunk, It starts with 0 for descriptions of the documents and fields in the chunks collection.

See following example:
cursor = db.fs.chunks.find({files_id: myFileID}).sort({n:1});
GridFS index allows efficient retrieval  of chunks using fields _id and n values.

Note: If your driver does not create this index, to fix this use the following operation

db.fs.chunks.createIndex( { files_id: 1, n: 1 }, { unique: true } );

No comments:

Post a Comment

Please do not enter any spam link in the comment box.

NUnit : Introduction

There are several unit test tools in the market, but one of them is NUnit, the most popular tool for doing unit testing. So in this tutorial...