wuchang
wuchang

Reputation: 3069

How should I understand mongoDB GridFS?

I am now using perl script client to store some big data into mongoDB .But now I met a problem ,some document exceeds the size limit of 16M,so ,I have to choose GridFS.From the GridFS document ,I read this:

GridFS is a specification for storing and retrieving files that exceed the BSON-document size limit of 16MB.

Instead of storing a file in a single document, GridFS divides a file into parts, or chunks, [1] and stores each of those chunks as a separate document. By default GridFS limits chunk size to 256k.

It really make me confused.What does it mean by "file"?"Instead of storing a file in a single document",it means , mongoDB stores a file in a single document without using GridFS,right ?But I think it should say:"Instead of storing a document in a single file,...".So ,the relationship and difference between "file" and "document" make me confused.

Upvotes: 0

Views: 746

Answers (1)

Sammaye
Sammaye

Reputation: 43884

What does it mean by "file"?

A file. A word document, Excel spreadsheet, HTML file anything that is a file. GridFS is designed for file storage.

it means , mongoDB stores a file in a single document

MongoDB does not do anything, it does not even manage GridFS, the documentation assumes you come to GridFS after encountering the limited size of a single document, as you have.

Instead of storing a document in a single file,...

Nope, that is incorrect. What is a document? MongoDBs own records are called documents, how can you store those within files in the database? You store data within documents in the database.

So ,the relationship and difference between "file" and "document" make me confused.

File is a physical file and a document is basically a row.

Upvotes: 1

Related Questions