Unanswered: Should I store images in the db or in a folder?
While browsing some php code yesterday I found out that it was possible to store images in a database in the form of 'blobs'.
I currently have a website that allows members to upload a profile picture of themselves. The pictures are renamed with a time/date hash and the link to the users picture is stored in the database. The actual thumbnail itself is stored as a jpg in a folder.
My question is this...
From a scaleability point of view, is this the right way to be doing this? I currently have around 1500 members with about 50 new ones joining every day. The site is really beginning to take off and I'm wondering whether a better way would be to store the pictures themselves in the database?
What are the pro's and con's of this??
I notice in myPhpAdmin that it will only allow me to export/import a max of 50Mb so I'm thinking that this would be used up a lot quicker if I store images in the database.
However, I'm also unsure of how many images I can hold in the folder and what effect, say, 50,000 or 500,000 images would have in one folder??
Can anyone give me any advice on the best solution for this?
I wondered how facebook do it as they have obviously got millions of user profile pictures to deal with....??
A couple of years ago someone actually did some research whether to store images (blobs) in the database or not and the outcome was quite interesting I think.
The bottom line of that research:
Originally Posted by Russell Sears, Catharine Van Ingen, and Jim Gray
The study indicates that if objects are larger than one megabyte on average, NTFS has a clear advantage over SQL Server. If the objects are under 256 kilobytes, the database has a clear advantage.
I have no idea to which extend this can be "transferred" to other databases. But I think the general conclusion is probably similar with other DBMS. The size of the blobs will most definitely change when using a different DBMS and/or filesystem
Some great replies there. Thanks to r937 and shammat.
I think I'll just stick with the method I use now. The images are only around 10K so they could go in a database but for the extra hassle and the negligible benefits I think the system I have at the moment is fine.
Thanks again for your wise words and input. It is very much appreciated.