Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Storing images in MySql

0 views
Skip to first unread message

Maxim Maletsky

unread,
Apr 16, 2002, 4:52:22 PM4/16/02
to Fifield, Mike, php-g...@lists.php.net
I personally think, storing images in DB (any kind of RDBMS that
supports it only because other DBs do) is:

*Good* because makes it portable and easily administered,
*Bad* because obviously, more flexible things get - less performance you
achieve.

In my opinion, unless you have no *real* need to do so, you can still
leave the images in your files system, just organize them well and use
DB for associating the data and referencing to them.

I know it doesn't really answer your question, but think about it - if
you store all the pictures in one directory, as they get over (1024?)
you'll start suffering from that very issue that I never encountered
personally yet but am aware of - file system limits. Storing them all in
a DB would give you flexibility and more headaches about the
performance. :-)

Sincerely,

Maxim Maletsky
Founder, Chief Developer
ma...@phpbeginner.com

PHPBeginner.com (Where PHP Begins)
www.phpbeginner.com <http://www.phpbeginner.com/>





-----Original Message-----
From: Fifield, Mike [mailto:Mike.F...@schwab.com]
Sent: Tuesday, April 16, 2002 9:48 PM
To: php-g...@lists.php.net
Cc: 'Maxim Maletsky'
Subject: Storing images in MySql

After posting my question about performance earlier this morning it was
suggested that I also store the jpg's in the database, (thanks Maxim). I
did a little research and got a lot of conflicting information on
weather this is a good idea or not. For example the following url states
that you suffer a 30% performance hit by doing it this way.
http://www.zend.com/zend/trick/tricks-sept-2001.php
Is anyone out there running a website that stores images as binary data
in MySql that could comment on this?
Any and all comments are welcome.

Mike



Mike Fifield

unread,
Apr 16, 2002, 3:48:29 PM4/16/02
to php-g...@lists.php.net, Maxim Maletsky

Julio Nobrega

unread,
Apr 16, 2002, 4:07:05 PM4/16/02
to php-g...@lists.php.net
From the mysql manual (http://www.mysql.com/doc/T/i/Tips.html):

"When using a normal Web server setup, images should be stored as files.
That is, store only a file reference in the database. The main reason for
this is that a normal Web server is much better at caching files than
database contents. So it it's much easier to get a fast system if you are
using files."

I guess Mysql developers are a good reference ;-)

--
Julio Nobrega.

Tô chegando:
http://www.inerciasensorial.com.br
"Mike Fifield" <Mike.F...@schwab.com> wrote in message
news:FFE9B7BE532CD411872F...@n6010vmx.nt.schwab.com...

Michael Kimsal

unread,
Apr 16, 2002, 6:25:49 PM4/16/02
to php-g...@lists.php.net, Mike Fifield

*Storing* images in the database is only half the battle - you need to
have another script to pull them out and display them.

The only situation where this makes sense is if you want/need to
programmatically control access to images. Just like you can control
access to various other bits of data in the database, you can also
control access to specific image data in a database - but it's an extra
step to pull it out. An extra HTTP request, I should say.

If you don't have a need to programmatically control access to image
files, don't bother putting them in a database. Let the filesystem do
what it's meant to do - serve files.

Michael Kimsal
http://www.phphelpdesk.com
Guaranteed PHP support when you need it
734-480-9961

0 new messages