We can save an image with 2 way
- upload image in Server and save image url in Database.
- save directly image into database
which one is better?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s a really good paper by Microsoft Research called To Blob or Not To Blob.
Their conclusion after a large number of performance tests and analysis is this:
if your pictures or document are typically below 256K in size, storing them in a database
VARBINARYcolumn is more efficientif your pictures or document are typically over 1 MB in size, storing them in the filesystem is more efficient (and with SQL Server 2008’s
FILESTREAMattribute, they’re still under transactional control and part of the database)in between those two, it’s a bit of a toss-up depending on your use
If you decide to put your pictures into a SQL Server table, I would strongly recommend using a separate table for storing those pictures – do not store the employee foto in the employee table – keep them in a separate table. That way, the Employee table can stay lean and mean and very efficient, assuming you don’t always need to select the employee foto, too, as part of your queries.
For filegroups, check out Files and Filegroup Architecture for an intro. Basically, you would either create your database with a separate filegroup for large data structures right from the beginning, or add an additional filegroup later. Let’s call it “LARGE_DATA”.
Now, whenever you have a new table to create which needs to store
VARCHAR(MAX)orVARBINARY(MAX)columns, you can specify this file group for the large data:Check out the MSDN intro on filegroups, and play around with it!