Should I use attachments?

37 views
Skip to first unread message

Andrew Stephens

unread,
Dec 4, 2013, 7:52:24 AM12/4/13
to rav...@googlegroups.com
I'm storing a collection of documents (in the thousands, probably no more than 20,000) in my database. There are no indexes defined - the documents will only ever be retrieved by ID. 

I now have a requirement to store the contents of 3 text files against each document. Two of these files will never be more than a couple of kb in size, while the third may be anything up to 100kb, very occasionally more (up to several Mb).

The contents of these files will never need to be searchable or updateable - they will only ever be retrieved for display in the UI.

What would you recommend as the best approach for storing these - as attachments, as properties within the "owning" document, or as document(s) in their own right?


Khalid Abuhakmeh

unread,
Dec 4, 2013, 8:10:04 AM12/4/13
to rav...@googlegroups.com
I recommend you don't use attachments, because it is just way easier to solve using blob storage on Azure, AWS, or write your own service to store files. I just ignore attachments exist in RavenDB myself, but maybe someone else can chime in with their experience. I currently store all my files on disk somewhere on the network.

Andrew Stephens

unread,
Dec 4, 2013, 8:13:00 AM12/4/13
to rav...@googlegroups.com
It's worth mentioning that while my UI will retrieve a number of documents (say 50), a text file will only be displayed when the user clicks a button (which will be rarely). So I guess storing the text files in the "owning" document is best avoided, merely for the fact that I would be loading all this additional information unnecessarily.

So do I store the files as attachments, or could I just store them as documents in their own right? I can kind of see the purpose of attachments for binary blobs but not sure if it's overkill for what I need?


Khalid Abuhakmeh

unread,
Dec 4, 2013, 8:18:19 AM12/4/13
to rav...@googlegroups.com
I find that having them on disk makes it way easier for backup and recovery purposes. If you want to store them in RavenDB you could "rebuild" them later if they are stored as documents (POCO), but I personally would not recommend blob storage in RavenDB. It just lead to a ton of headaches in the past, and the tooling for attachments in RavenDB is very minimal, which makes managing them very difficult. Store the metadata in Raven, and use something else to store the blobs.
Reply all
Reply to author
Forward
0 new messages