Skip to content

DOCS-656 - GridFS faq #417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 12, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions source/faq/developers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,46 @@ flag to modify the file preallocation strategy.

.. seealso:: This wiki page that address :wiki:`MongoDB disk use <Excessive+Disk+Space>`.

.. _faq-developers-when-to-use-gridfs:

When should I use GridFS?
-------------------------

For documents in a MongoDB collection, you should always use
:term:`GridFS` for storing files larger than 16 MB.

For files on your file system, storing the files in a MongoDB database
through GridFS provides advantages in a number of situations:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sentence needs some help. the first use of filesystem is too ambiguous


- If your file system limits the number of files in a directory, you can
use GridFS to store as many files as needed.

- When you want to store file metadata (such as description, download
count, and MD5 hash) together with the file itself. Storing the file
data and metadata is important in many scenarios and supported by
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the meaning of "together" is vague here. I'd probably kill this bullet as it's not distinguishing, and I might move it down lower in the list regardless.

in some sense, because metadata and content are in different collections, gridfs doesn't quite provide "storing metadata and data together," though that might be splitting hairs.

GridFS.

- When you want to keep your files and metadata automatically synced.
If you set up replication, MongoDB replicates both the files and their
metadata so things won't get out of sync.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems absurd as written becasue "synced" doesn't have an object so its more of a features without the corresponding usecase, which is weird.)

The idea/approach should be more like: when you want to store files on systems in multiple data centers, you can use a gridfs store in combination with a replica set to ensure that each facility has a local (read) copy of all files that is always (roughly?) current.


- When you want to access information from random sections of large
files without having to load whole files into memory. GridFS lets you
access sections of files without having to read the entire file.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add note about this being dependent on driver implementation.


Do not use GridFS if a file is under the 16 MB limit and you need to
update the file atomically. Instead, consider either:

- Storing the file manually within a single document. This can be
accomplished using the BSON BinData datatype. For details on using
BinData, see the :doc:`drivers </applications/drivers>` documentation
for your driver.

- Storing multiple versions and specifying which version is current.
This can be changed atomically after the new file is uploaded.

For more information on GridFS, see :doc:`/applications/gridfs`.

How does MongoDB address SQL or Query injection?
------------------------------------------------

Expand Down
3 changes: 3 additions & 0 deletions source/reference/glossary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ Glossary
of the official MongoDB drivers support this convention, as
does the ``mongofiles`` program.

.. todo When source/applications/gridfs.txt goes live,
add a link here.

.. seealso:: :doc:`/reference/mongofiles`.

md5
Expand Down