Results 1 to 5 of 5
  1. #1
    Keeper of The Iron Tail zAlbee's Avatar
    Join Date
    Jan 2002
    Location
    California
    Posts
    590

    Database file storage

    I'm setting up a database that can store user-uploaded files amongst other things. It's a PHP MySQL server. So I go to all this trouble to set everything up, with a BLOB field for the file, and varchars/ints for mime-type, filename, filesize, etc. Now I'm reading that some people think storing the file directly into the database is terrible for performance, and it would be better to store the file in a directory and just store the path in the database.



    Maybe it is true, but I have never read about this "performance hit" in official documentation.

    Any thoughts?


    • Advertising

      advertising
      EmuTalk.net
      has no influence
      on the ads that
      are displayed
        
       

  2. #2
    At your service, dood! ScottJC's Avatar
    Join Date
    Apr 2002
    Location
    Scotland
    Posts
    3,159
    Storing a file in a database is harder than pointing to its path, but it adds security, i.e. file.php?db=filename.type, because the path of the true file is completely embeded in the database and nobody knows exactly where the database is then leeching of other sites is considerably harder.

    However: The database would increase in size exponentially as it is used, so it may be a better idea to store it as seperate files. The larger the database the slower it becomes and your php/cgi whatever will have to be involved throughout the entire progress of the user downloading.

    You can get around that though by using more than one database and perhaps creating new ones on the fly.

  3. #3
    Plugin coder / Betatester Falcon4ever's Avatar
    Join Date
    Mar 2002
    Location
    The Netherlands
    Posts
    1,253
    Storing files as a blob in a MYSQL db is not recommended ,
    it's better to make a filehash, renamed the uploaded file and store the properties of those into the mysql db.

  4. #4
    Moderator Cyberman's Avatar
    Join Date
    Nov 2001
    Posts
    1,824

    Of which I'm fairly certain

    That's what this site does.

    The alternative is to create 2 seperate databases 1 with the BLOB files and 1 with the Reference too that file. This at the very least prevents security issues. The big problem comes when you perform maintenance on the database. And don't EVER say that it won't be necessary. Deleting a 1 meg section from a database that's about 1421 megs in size, is a nightmare.

    Have fun, I suggest experimenting before you end up comitted to your design

    Cyb

    We are slaves of our own designs.
    Progress (n.):
    The process through which the Internet has evolved from smart people in front of dumb terminals to dumb people in front of smart terminals.
    -------------------------------------------------------------------
    Recursive (adj):
    see Recursive

  5. #5
    Keeper of The Iron Tail zAlbee's Avatar
    Join Date
    Jan 2002
    Location
    California
    Posts
    590
    Thanks guys. From what I've read, using the filesystem is much faster, and is much better for the database. I like your suggestion Falcon4ever, I think I'll do something similar .

    As for file retrieval... is there any combination of HTTP headers that will both redirect to a file and rename it (ie. set the name for downloading)? Otherwise I think I'm stuck with doing a PHP readfile() =P
    Last edited by zAlbee; July 19th, 2006 at 23:04.

Similar Threads

  1. Metroid Prime .pak format?
    By Elpenguino in forum General GC Emulation Discussion
    Replies: 80
    Last Post: September 21st, 2010, 22:23
  2. DVD-RW Issues
    By Jaz in forum TechTalk
    Replies: 11
    Last Post: March 31st, 2006, 23:15
  3. Helping all the newbies with girigiri
    By wizo5454 in forum Sega Saturn Emulation
    Replies: 7
    Last Post: April 18th, 2005, 00:14
  4. can't write any data to blank CD. help please!!
    By ice88chen in forum TechTalk
    Replies: 9
    Last Post: July 23rd, 2004, 19:19

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •