Images in mysql??

Discussion in 'Web Design and Development' started by macmanmatty, May 16, 2007.

  1. macmanmatty macrumors regular

    Joined:
    Jul 10, 2005
    Location:
    I have calculated my velocity so precisely that a
    #1
    I know I can insert images into a mysql database, but is this reccommened for websites with lot of large pictures being stored in the database? How fast will it be?? Will any hosting services allow this?? Or should I just learn how to use a file system?


    macmanmatty
     
  2. Stampyhead macrumors 68020

    Stampyhead

    Joined:
    Sep 3, 2004
    Location:
    London, UK
    #2
    You can include your images in your MySQL db, but it will quickly eat up disk space. A smarter thing to do would be to store the images in a folder and reference them in the db by name. Then when you are listing the image on your site you list the path to your images folder and then dynamically pull in the image name(s). I do it that way all the time and it works great.
     
  3. virus1 macrumors 65816

    virus1

    Joined:
    Jun 24, 2004
    Location:
    LOST
    #3
    ditto, brotha
     
  4. elppa macrumors 68040

    elppa

    Joined:
    Nov 26, 2003
    #4
    Why do the images take up more space in the database than they would sitting in a folder? Surely a 36KB jpg (example) is a 36KB jpg.

    Can you explain as I am genuinely curious. Is it something to do with the way they are stored?
     
  5. Benjamin macrumors 6502a

    Benjamin

    Joined:
    Oct 27, 2003
    Location:
    Portland, OR
    #5
    He isn't saying it will eat up more, but rather the actual database size will be much larger. (to be honest I bet if you totaled up the bytes from the image reference column plus the file and compared it with a pointer reference and a blob field that held a image, the former would end up being larger)

    While I agree with using references to retrieve the file it i theory it would be faster to add a blob field and store your images in it and then retrieve with a pointer, but unless you are doing in house production with still multi-MB files (like ILM uses) you aren't really going to see any difference. Further your host would probably frown with you using up database space and ram when images were retrieved from the database. Last over the web it won't make a difference since the bottlenecks are usually not hosts but rather client connections.

    Anyway... I do agree with Stampyhead that is nearly all web based galleries do it.
     
  6. macmanmatty thread starter macrumors regular

    Joined:
    Jul 10, 2005
    Location:
    I have calculated my velocity so precisely that a
    #6
    THnaks for all the replys I guess I will just store the images on the server and reference them in the database. seems to be the best way to go.

    macmanmatty
     

Share This Page