onlyican Posted July 26, 2007 Share Posted July 26, 2007 Hey people. Been a while since I posted in here. Been too busy. Anyway, I am after Advice from the brains. I have a website which runs a lot of MySQL queries. As most big complex sites do. This site has a CMS (Content Management System) So in Admin, the user can edit the content of the page, then Store this as a preview, either Save changes, or if User does not have Privileges, someone who does can come along and Approve changes. The MySQL Table holds the Users ID of the User who last updated the page content. But we want to log the Users ID for EVERY change made, not just the last change. 2 Options: Create new Table, to log the entries Use a file, write to the file every change, and user ID What is quicker and easier on the server load. I would like to know why, so please don't just say MySQL or File. Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted July 27, 2007 Share Posted July 27, 2007 MySQL. The file will be faster at first, but as it grows in size it will get more cumbersome to use. Every time it gets written to the OS has to open the whole file, then append to it, then close it. If that file is several MB in size, then that can eat system resources. Additionally, you will encounter a problem with file access...what happens when PHP, which is multi threaded, tries to access that file with 2 or more of it's threads at the same time? Additionally, using the file makes it much much slower and more difficult to do the associations when you want to look at the history for a particular piece of content or user. You are already going to have to use a join in your user table to get the user name when you are doing a "history", so, rather than having to read your file, then pull the relevant information, you can do a single query with a join. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.