Forum Moderators: coopster

Message Too Old, No Replies

Image Streams - DB or file

what is your preference and why?

         

mifi601

9:23 pm on Nov 9, 2004 (gmt 0)

10+ Year Member



when you save images, do you prefer to save them directly in the DB or in separate files, saving only the image name in the DB?

And why do you prefer to do so?

mincklerstraat

9:30 pm on Nov 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Definitely as files - the people at mysql.org also advise saving in files for most cases, since this is also quicker than getting them from a db, and you never really would have occasion to need to 'search' this info.

Also, just the way HTML is constructed, you have to do a separate <img src...> for every image - every image is then got by a little php file, but this then has to make its own connection to your database. When it comes to speed in databases, the initial connection is often one of the biggest factors (if you don't have bloated code). Means slower page generation time, and more processor time.

mifi601

9:34 pm on Nov 9, 2004 (gmt 0)

10+ Year Member



mincklerstraat - thank you so much!

I have read somewhere that the speed difference can be as much as 30x would you confirm this?

I was wondering about all those different connections to the DB ..

thanks again!

jatar_k

9:57 pm on Nov 9, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the specific impact would vary depending on what you are doing with it.

complex joins on tables with huge amounts of binary data, that would be fun. I bet with a few simple queries and a db loaded with images we could make a server cry inside a few seconds. ;)

mifi601

10:19 pm on Nov 9, 2004 (gmt 0)

10+ Year Member



I found in several fora that quite a few people seem to store image data right in the DB ...

do you think that there's a benefit in terms of security, not having to set directory attributes at 777?

jatar_k

10:32 pm on Nov 9, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



now you've done it mifi601 ;)

security / performance tradeoff in image uploads [webmasterworld.com]

regardless of the above discussion, storing images in your db is just a very bad idea, no matter what.

mifi601

10:47 pm on Nov 9, 2004 (gmt 0)

10+ Year Member



thnaks, jatar_k - I had missed that thread. I guess my take on the security issue will be:

Make the directories 777, let the server breathe, who wants to get in will - no matter what ...