Jump to content

Storing Images in Database - Makes Page Load Much Slower?


justhost

Recommended Posts

Hello all,

 

I have just taken over a site which was developed in php / mySQL. It is a large shopping cart system. I was shocked to learn that their mySQL database was over 1GB in size. I have seen forum DB's get very large but never that large for a shopping cart site so I investigated further. It turns out they have stored all of the product images and I believe even many of the basic site images in the database itself as a longblob type. There is one table that is 860MB in size. Although I knew you could store images in this fashion I have personally never done this. Now my question I have is would this cause the site to load very slow. The client has been complaining that all of the product images load extremely slow since the site was changed from osCommerce over to this new custom site? When I sit and think about the logic it makes sense that it would be slower and would also be much more resource intensive. I wouldnt think that the images would ever cache then on the client PC and that evey time the page loads it is going to have to transfer all of the images from the DB to the client...

 

For example once a page has loaded completely and then you click refresh it takes nearly as long to load the page again as it did the first time. That simply doesnt make sense.

 

Does anyone have any input or comments on this?

 

I have uploaded a demo of the site at the following: http://www.justhosting-test.com

 

Thank you.

 

Keith

Link to comment
Share on other sites

locate teh part of the script that garbs the image from teh database - instead of echoing out the image - save it into a directory withd a suitable name.  The db structure should then be alted - add a filed to store the apth to the new image and set the blob field to NULL.

 

update teh cms to upload the image to this new directory also and have it store the path instead of the blob. Once all blob field records are null remove the field altogether....

Link to comment
Share on other sites

I do not think that is what he is asking... Yes putting images is a very bad security risk and makes your website run choppy and slow! A better way to do this is to have the picture somewhereon your ftp and then to have a mysql and php script to direct the img scr to the location specified in the php! Thats how my sites done and it works very fast. Ive got about 7 tables and in total it equals less than 2 Mb's

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.