Jump to content

Mysql update vs. File Write


wolfmanp

Recommended Posts

Posted this in the php help section but thought some mysql experts might know a bit more.

Hi there, I'm writing a counter for pages on a high traffic website. My diea is to have text files for every item and then update thise files by adding a 1 to it so the size increases by 1 byte every hit. Then when the filesize goes over say 15 bytes then I do an update to the DB  adding 15 to the hits column to save having to do a DB update call on every hit.

My question is if I'm doing a file IO every page display will this bog down the sytem moreso then doing a mysql update? Do you guys think my idea is a good one?

Actually writing this out I think I've thought of a better idea. What about a cron job every 10 minutes or so which scans the db and adds all the hits to the db every 10 minutes.  This would save on extremely popular pages that get over a thousand hits in that time. Rather than doing around 60 updates in 10 minutes it would do 1 update. What do you guys think?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.