MySQL Question - Storing images in database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
HormonX
Forum Commoner
Posts: 50
Joined: Tue Dec 10, 2002 7:43 pm
Location: Toronto

MySQL Question - Storing images in database

Post by HormonX »

I just came upon a project that i have to redesign and rework a bit. Question i have is how efficient is storing images in a db , previous person used a binary LONGBLOB. I noticed that even with few images there seems to be a lot of overheard. Won't that slow the database, wouldn't it be easier and faster to store these images as files?

If anyone could shed some light on that it would be great.

Thanx

Greg
User avatar
bmcewan
Forum Commoner
Posts: 55
Joined: Wed Jun 02, 2004 7:19 am
Location: West Yorkshire, UK.

Post by bmcewan »

Personally i wouldn't store any files in that manner.

I would always store the filename and save the physical file in the filestructure.
When initially storing the file i rename it to a random string, first checking to see if that random string already exists, chosing another if it does. Then save the file in the filestructure and the filename in the db.
HormonX
Forum Commoner
Posts: 50
Joined: Tue Dec 10, 2002 7:43 pm
Location: Toronto

Post by HormonX »

I totaly agree. I wouldn't do that i was just curious if there were any advantages to storing a while image a binary BLOB. As i mentioned above i noticed a lot of issues with the database and that is without too much data being stored. I will see if the customer would want to redo the while structure and start from scratch.

Thanx.
Post Reply