What's the fastest way to store data?

Discussion in 'PHP' started by Sky AK47, Jun 25, 2009.

  1. #1
    Ok...I need to store thousands of data to MySQL or files.
    But I need to know what the fastest way would be..I prefer files as they are easier to manage in this case, but will it be faster?
    MySQL
    - loop
    -- check if data already in table (1 query)
    -- store data (1 query)
    - endloop
    Code (markup):
    File
    - loop
    -- check if file exists (file_exists)
    -- create and write to file (fopen, fwrite and fclose)
    - endloop
    Code (markup):
    Thanks in advance.
     
    Sky AK47, Jun 25, 2009 IP
  2. hassanahmad2

    hassanahmad2 Active Member

    Messages:
    243
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    60
    #2
    File operations generally take more time. So MySQL is always the best choice in any circumstance allowing many connections simultaneously.
     
    hassanahmad2, Jun 25, 2009 IP
  3. Sky AK47

    Sky AK47 Member

    Messages:
    298
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    45
    #3
    Even if the database is going to contain more then 1gb?
     
    Sky AK47, Jun 25, 2009 IP
  4. hassanahmad2

    hassanahmad2 Active Member

    Messages:
    243
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    60
    #4
    Yes, 1gb is most common in big websites.
     
    hassanahmad2, Jun 25, 2009 IP
  5. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #5
    The more data, the greater a database will outperform any sort of file based storage. File operations (even very simple ones) on folders with thousands/millions of files take forever. A database is definitely the way to go.
     
    jestep, Jun 25, 2009 IP