justhost Posted August 29, 2007 Share Posted August 29, 2007 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 Quote Link to comment Share on other sites More sharing options...
justhost Posted August 29, 2007 Author Share Posted August 29, 2007 Does anyone have any input on this? Quote Link to comment Share on other sites More sharing options...
nathanmaxsonadil Posted August 29, 2007 Share Posted August 29, 2007 Change to images Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 29, 2007 Share Posted August 29, 2007 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.... Quote Link to comment Share on other sites More sharing options...
lightningstrike Posted August 30, 2007 Share Posted August 30, 2007 Simply edit the displayimage.php script. Since you appear to be using the built-in php session support. simply include before the session_start(); session_cache_limiter("public"); or something more advanced http://www.php.net/session_cache_limiter which will allow the dynamic images to cache properly. Quote Link to comment Share on other sites More sharing options...
Crew-Portal Posted August 30, 2007 Share Posted August 30, 2007 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.