Can we store images in database

0 votes
Sep 27 in Database by Omaiz
• 560 points
15 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 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 in Database by sampriti
• 1,100 points
83 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 in Database by sampriti
• 1,100 points
32 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,240 points
152 views
0 votes
2 answers

Types of relationships in Database

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

answered Aug 16, 2018 in Database by zombie
• 3,690 points
45 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,130 points
52 views
0 votes
1 answer

Atomicity and Aggregation in Database

Atomicity is the condition where either all the ...READ MORE

answered Aug 22, 2018 in Database by DataKing99
• 8,130 points
137 views
0 votes
1 answer

Fragmentation in Database

Fragmentation is a feature which controls the ...READ MORE

answered Sep 4, 2018 in Database by darklord
• 6,150 points
31 views
0 votes
1 answer

What is checkpoint in Database?

Checkpoint declares a point before which all ...READ MORE

answered Sep 4, 2018 in Database by darklord
• 6,150 points
181 views
0 votes
1 answer

How does database indexing work

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

answered Oct 4 in Database by Daric
• 500 points
10 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 in Database by Daric
• 500 points
12 views