Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1876 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Images in a database?

Thread title: Images in a database?
Closed Thread    
    Thread tools Search this thread Display Modes  
06-09-2008, 02:47 AM
#1
BlaineSch is offline BlaineSch
BlaineSch's Avatar
Status: Member
Join date: Mar 2005
Location: Trapped in my own little world
Expertise: Web Applications
Software: Notepad++
 
Posts: 385
iTrader: 0 / 0%
 

BlaineSch is on a distinguished road

Send a message via AIM to BlaineSch Send a message via MSN to BlaineSch Send a message via Yahoo to BlaineSch Send a message via Skype™ to BlaineSch

  Old  Images in a database?

What are the ups and downs of having images stored in a database? My site gets new pictures every once in a while from users if I were to store these in folders I would have extensive folders if I wanted them organized. If they were in a database I could find them easy and there are no need for all those folders. But would this slow me down? Having a huge database would make the querys go slower correct?

06-09-2008, 03:37 PM
#2
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

Having a huge database doesn't really affect the speed at which you could get the results. Also, you would only store image paths and you would still need the folders, however you wouldn't need to search through all them.

06-09-2008, 03:54 PM
#3
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

To sum it up quickly, yes storing images in the database (ie. storing BLOB data, not just paths to files) would slow things down considerably.

With a correctly (or, not badly) structured database there shouldn't be much impact on the normal queries that you already make but there are bigger concerns. For every time someone tries to access the image, you'll need to load up a script (ruby, php, python, whatever) to interpret the request, connect to the database, find the image, bring back the image data and output it. This will take much more time, and considerably more processing power, than simply letting the web server find the file stored in the file system normally.

The only time I've gone for the route of storing the image/file data in a database is when I needed fine grained control of who exactly gained access to the file where the overhead of loading up a script file and database connection was done anyway for the access control.

With an organised folder/file structure, I'd certainly recommend storing them in the file system rather than in a database.

06-09-2008, 08:42 PM
#4
BlaineSch is offline BlaineSch
BlaineSch's Avatar
Status: Member
Join date: Mar 2005
Location: Trapped in my own little world
Expertise: Web Applications
Software: Notepad++
 
Posts: 385
iTrader: 0 / 0%
 

BlaineSch is on a distinguished road

Send a message via AIM to BlaineSch Send a message via MSN to BlaineSch Send a message via Yahoo to BlaineSch Send a message via Skype™ to BlaineSch

  Old

I was thinking so I guess ill just stick with putting paths in the database. Thank you for the help!

06-11-2008, 12:08 AM
#5
masfenix is offline masfenix
Status: Member
Join date: Mar 2006
Location: t.dot canaada
Expertise:
Software:
 
Posts: 182
iTrader: 1 / 100%
 

masfenix has a little shameless behaviour in the past

Send a message via AIM to masfenix

  Old

Acutally in .net LINQ you can do something called delay loading. It's actually hard for me to explain it so heres a quote from other site:


For a simple example of when I’d want to-do this, consider the “Category” entity class we modeled above. The categories table inside “Northwind” has a “Picture” column which stores a (potentially large) binary image of each category, and I only want to retrieve the binary image from the database when I’m actually using it (and not when doing a simply query just to list the category names in a list).
So as you can see, while the query is there, its not actually fetching the info until its acutally needed.

If your well advanced in PHP, you can somewhat try to create this but i have never seen it happen.

on the other hand, if you have < 1000 users/pics then give or take the site usage you should be okay.

06-27-2008, 12:31 PM
#6
aeryes is offline aeryes
aeryes's Avatar
Status: I'm new around here
Join date: Jun 2008
Location:
Expertise:
Software:
 
Posts: 9
iTrader: 0 / 0%
 

aeryes is on a distinguished road

Send a message via ICQ to aeryes Send a message via MSN to aeryes Send a message via Skype™ to aeryes

  Old

For a recent project I've had a dilemma... what to do to make image caching work (to avoid gdlibrary processing all the time) and had choices:
1. throw images in db
2. throw only image paths to db
... and chosed none, because with a hundred or so images being cached each minute it would slow the db searching considerably.

What I did is created a unique name based on unique params each picture had, md5()-ed those filenames, and could easily reconstruct names with params that are already loaded. That means - no calls to DB were made, and no calls for writing to db also.

The bottom line is: if you know the exact path to the image, it will display a lot faster then calling it from db in any way.

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed