"Ahbaid Gaffoor" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Thanks to all who helped with my earlier questions on pulling BLOB data > out of Oracle using PHP. > > I am however finding that performance is slow when downloading huge > files from the database. > > A typical 2Meg GIF file being downloaded from Oracle via. PHP is taking > about thirty seconds. > > Everything (database, web server, development box) are all on a 100 > Megabit Switched ethernet setup. > > > 1) Are there any pitfalls or guidelines when working with BLOBs and web > apps? > > 2) Is there any advice for or against storing images as blobs in a > database? Or is it better to store them on the web server file system? > > So far I am finding the web server file system to be faster, but I tend > to think that it is less manageable from a relational data perspective. > > thoughts? > > thanks > > Ahbaid
As 1) and 2) are closely related, I'll write the answer to both at once. The only real advantage to storing files in BLOBs that I can think of is replication. If your database is replicated over X amount of servers, you'd have to write seperate procedures to replicate the images that go with the database, as they are not stored in the DBMS. That can be quite annoying if you consider all the issues that come with it (locking etc.). Application logic (or, right, manageability) is another issue that jumps to mind (especially when trying to write generic database handling stuff), but minor, and often you can overcome that problem by abstracting filesystem logic in its design. In some situations, it's simply impractical. Imagine a page with thumbnails, where the data for the thumbnails has to be pulled from database BLOBs. You'd have to have a seperate request to the database for every thumbnail on the page, as you have to spit out different headers for images (you'd get those <img src="get_my_darn_blob.php?recid=5"> a lot). If you didn't store them in a BLOB, you could simply output the paths to the images and they'd be fetched from the webserver's filesystem. Another disadvantage is that doing a lot of updating operations on BLOB fields tends to fragment your harddisk pretty fast. Another issue, as already mentioned, is speed. While it should be said that speed depends on how the DBMS optimizes the search operations thus will vary between database servers, it is usually just faster to fetch a file directly from the filesystem without interference of the DBMS. In high-traffic situations, you're likely to notice the speed difference. There are probably more disadvantages, but this is what I can come up with from the top of my head. So, if you must depend on replication, that's a good reason to choose BLOBs for storage. In any other case I'd suggest you don't. Regards, Leendert Brouwer Freelance consultancy http://www.daholygoat.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php