Which is better: included file or pulling from a mysql database?

Discussion in 'PHP' started by mma freeroll, Feb 6, 2009.

  1. #1
    I've got a section of my site that allows users to post "comments" on a certain type of page.

    Which option do you guys think would be better (as far as speed and performance goes):

    - pulling the comments from a mysql database on the fly

    - create pages and throwing them into the page via "include"

    - rewrite the actual page as a .html every time another comment is posted

    Just wondering, thanks!
     
    mma freeroll, Feb 6, 2009 IP
  2. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #2
    how about pulling the comments from a DB on a schedule and including them >? Cron task every hour or so. Or update only when a new comment is added.
     
    shallowink, Feb 6, 2009 IP
  3. steelaz

    steelaz Peon

    Messages:
    47
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I would always prefer database. You have more control over data and unless your queries are very complex, it is faster then reading/writing to a file.
     
    steelaz, Feb 6, 2009 IP
  4. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #4
    Definitely gathering data from db, that's the best
     
    crivion, Feb 6, 2009 IP
  5. rohan_shenoy

    rohan_shenoy Active Member

    Messages:
    441
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Database allows much more easy manipulation than files.
     
    rohan_shenoy, Feb 6, 2009 IP
  6. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #6
    That statement's partially true. Reading from a file should be faster than a DB call. While DB calls do give you more options on what to do. If its a heavily frequented site, some type of caching should be employed. Just remember how long it takes for WP Blogs with Tons of comments to load. Do you want that for your site?
     
    shallowink, Feb 6, 2009 IP
  7. mentalic

    mentalic Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    A simple HTML page is the lightest that you can do concerning your server resources, which is however completely painful to manage. As mentioned earlier, a DB concept with a caching engine would be the ideal.
     
    mentalic, Feb 6, 2009 IP
  8. lui2603

    lui2603 Peon

    Messages:
    729
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #8
    For something as simple as a comments page I don't think there's much need to cache the db results but if there is a lot of traffic or it's more complex than I think then I would recommend Memcached
     
    lui2603, Feb 6, 2009 IP
  9. emily

    emily Well-Known Member

    Messages:
    1,252
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    175
    #9
    gathering data from database would be the best
     
    emily, Feb 6, 2009 IP
  10. InovvativeTech

    InovvativeTech Banned

    Messages:
    32
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #10
    My advice is to use PHP script with mysql database for comments section in your site, If you want to optimize it for SEO you can use rewrite rules using .htaccess
     
    InovvativeTech, Feb 7, 2009 IP
  11. mma freeroll

    mma freeroll Guest

    Messages:
    42
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #11
    That's what I was expecting.

    Thanks for all the responses. I'm going to try and do some speed tests on the server later.

    The site gets a decent amount of traffic, but nothing that should clog up a database too much.
     
    mma freeroll, Feb 9, 2009 IP