Can we store images in database

0 votes
Sep 27, 2019 in Database by Omaiz
• 560 points
992 views

1 answer to this question.

0 votes

Beware that serving images from DB is usually much, much much slower than serving them from disk.

You'll be starting a PHP process, opening a DB connection, having the DB read image data from the same disk and RAM for the cache as filesystem would, transferring it over few sockets and buffers and then pushing out via PHP, which by default makes it non-cacheable and adds an overhead of chunked HTTP encoding.

OTOH modern web servers can serve images with just a few optimized kernel calls (memory-mapped file and that memory area passed to TCP stack) so that they don't even copy memory around and there's almost no overhead.

That's a difference between being able to serve 20 or 2000 images in parallel on one machine.

So don't do it unless you absolutely need transactional integrity (and actually even that can be done with just image metadata in DB and filesystem cleanup routines) and know how to improve PHP's handling of HTTP to be suitable for images.

answered Oct 4, 2019 by Daric
• 500 points

Related Questions In Database

0 votes
1 answer

Can you please explain the difference between inner join and outer join in database?

Hi Suraj, You have a doubt regarding inner join ...READ MORE

answered May 28, 2019 in Database by sampriti
• 1,120 points
1,167 views
0 votes
1 answer

How can I check my all existing table in MySQL database?

Hi Pratik, I understand your problem regarding this ...READ MORE

answered Jul 1, 2019 in Database by sampriti
• 1,120 points
1,439 views
0 votes
1 answer

How can we perform common set operations (union, intersection, minus) in MS Excel?

The MATCH function can be used as ...READ MORE

answered Mar 31, 2022 in Database by gaurav
• 23,260 points
1,903 views
0 votes
1 answer

How can we achieve excel ceiling function with significance value in SQL Server

If the underlying data types and rounding ...READ MORE

answered Apr 4, 2022 in Database by gaurav
• 23,260 points
1,013 views
0 votes
0 answers

How to store image in SQLite database

I want to upload an image from ...READ MORE

Aug 22, 2022 in Database by Kithuzzz
• 38,000 points
3,068 views
0 votes
1 answer

Database Repair Options in Cassandra

Anti Entropy: Anti-entropy Repair is a process of ...READ MORE

answered Jun 28, 2018 in Database by kurt_cobain
• 9,350 points
2,152 views
0 votes
2 answers

Types of relationships in Database

There are 3 types of relationships in ...READ MORE

answered Aug 17, 2018 in Database by zombie
• 3,790 points
2,942 views
0 votes
1 answer

Indexes in Database

The index is a data structure that ...READ MORE

answered Aug 20, 2018 in Database by DataKing99
• 8,250 points
1,042 views
0 votes
1 answer

How does database indexing work

If you have a book about dogs ...READ MORE

answered Oct 4, 2019 in Database by Daric
• 500 points
739 views
0 votes
1 answer

MySQL query finding values in a comma separated string

To find MySQL query values in a comma-separated ...READ MORE

answered Oct 4, 2019 in Database by Daric
• 500 points
3,220 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP