Re: Should I put pictures into a database?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2007-11-22 at 06:22 +0000, Lester Caine wrote:
> Michael McGlothlin wrote:
> > I use a custom file system that caches large amounts of data in RAM.  
> > That way it's really fast and as easy to use as normal file system calls.
> 
> It's called a relational database ;)
> Seriously.
> Databases like MySQL do not handle BLOB's with any sensible control hence the
> againsts quoted. A decent database working in cooperation with the operating
> system should be as fast at returning a block of raw data as searching the
> file system to find the same block and hand that data to the following process
> transparently.
> Firebird has always handled BLOB's reasonably well, and with the incremental
> backup facilities now available, ALL of the data can be safely managed and
> replicated to secondary machines. Managing 100s of thousands of images in a
> directory structure may not be the best way of managing a large volume of
> data, requiring searching through a tree of directories to get to a file,
> while storing the same in a flat file system WITHIN a database SHOULD be a
> more efficient alternative.
> 
> Should I put pictures into a database? - depends on both the data base and the
> file system/OS :)

There's lots of reasons to do either. For one project I keep images in a
database. When the browser makes a request for the image via a specially
crafted URL it either gets a direct hit or invokes PHP's 404 handler.
Using the 404 handler I can then pull the image out of the database,
scale it's dimensions according to the URL and save to filesystem and
then set the header to status 200 and flush the image. using this
technique subsequent requests come from the file system while internally
I have the convenience of the database. Once a day I have a cron job
traverse the image version directory and purge any older than X days.

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux