Answer the question
In order to leave comments, you need to log in
Is it advisable to store images in a database?
I use MySQL, PHP.
I am making a posting system, the pictures of each post need to be saved somewhere.
Is it advisable to store images in a database? Or is it better to implement storage in folders with files?
Answer the question
In order to leave comments, you need to log in
It’s bad to store pictures in the database, and here’s why.
If the picture is in the database, then in order to pull it out, you need a php script that will send a request to retrieve it. Dynamic content will be generated, Apache is running.
If the picture is in a folder, then to display it, simply refer to it by URL. Here you can do without a script, therefore only nginx can work.
What is the point - nginx eats MUCH fewer resources compared to apache. You can google the statistics.
The only limitation when using storage in folders is that for *nix, a folder cannot contain more than 42-something thousand files (I can be wrong with the number, but that's not the point), so consider this aspect.
It's terrible to store images in MySQL, and use MySQL when you have Postgres.
In general, in the database, then in theory it is possible, in the same riak or mong - no problem.
Both methods have their advantages and disadvantages, but still storing as simple files is more organic. This is static that needs to be given to the user without the participation of scripts.
the picture itself in the folder, additional information in the database
Is it advisable to store images in a database?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question