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
https://forums.phpfreaks.com/topic/35443-mysql-update-vs-file-write/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.