3

in my java application I'm maintaining a users database and I have to store user account picture together with other details. i can store the photo in my database or I can store the image in my file system and store relevant path in the database. which one is more suitable in terms of memory and running time ?

4
  • If the picture is not big, I suggest you to store all datas in DB as in one DB access you will be able to get all datas you need. If you store the picture in a file system, you'll need to get the user ID (or whatever) in DB in order to find the user picture in file system. Two requests in this case. Commented Mar 26, 2014 at 9:20
  • @JGeo On the other hand, an image in the filesystem can be accessed by the fileserving facilities of the webserver at any time without running any Java code or SQL queries. For example if a website visitor caches an image -- visits 10 times and doesn't need the image -- but subsequently needs the image because the cache expired. Commented Mar 26, 2014 at 9:28
  • @JGeo But that's a very "web" related thing. If we're talking about a stand alone application with no web interface then you still have to rebuild the GUI Scene and render the image again -- so what you say may apply there. Commented Mar 26, 2014 at 9:30
  • 1
    @MihaiStancu : Yes you're right. It depends on the application concerned. But as I said in my first comment, storing picture in DB is only available if picture size is small. Otherwise he should stores them in a file system. Commented Mar 26, 2014 at 9:33

3 Answers 3

1

Reference taken from this article:

You should take decision based on your system complexity and scalability. I suggest you to go with File System and Database Storage is not allowable, but still it is advisable. Management is always easy with database storage, but will create a performance issue in some circumstances. Management is quite complex with file system, but you will get more performance.

Sign up to request clarification or add additional context in comments.

Comments

1

You should store file on file system. You can read about this on programmers stackexchange: https://softwareengineering.stackexchange.com/a/150787

Comments

1

File system is obviously faster if you have the option.

You can use varbinary if you have to insert it to your db.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.