开发者

SQL database or writing in text file with PHP?

I'm working on a football game online and am stocking player stats that need to be overwritten daily after simulations. (You don't need a database sample for my question, only to understand what is the pattern of my data (about 100 columns and 5 million entries): playerid, gamesplayed, touchdowns, runs, ...)

Considering that data will need to be manipulated often (SQL UPDATE and SELECT mostly), should I opt for stocking my data in a SQL database and doing multiple queries, or writing the data in a file on the开发者_Go百科 server with PHP writing functions? Which would reduce the server stress the most?


If you want your site to be scalable, use SQL. It might be more complicated than text files to set up, but you won't have to gut your entire infrastructure if you ever want to add more advanced features later on.


I will suggest you to use both of them, I'm sure that you wont always use the whole information from the mysql db. So, in MySQL keep the basic information for players, like the id and the name, next... if you really want to mess around with txt files, than make a unique txt files for every single player (do this with PHP, 1st check if there is already file with this name, the name should be the id of the player, if there isn't... than create 1) and in this files store the information which is often updated. I suggest you to test the both ways: with Mysql + TXTs and only MySQL. Cheers


Generally speaking, if you have that many entries a database is probably the way to go. However this depends your exact usage.

If you are just generating all the results at once and then not really doing lookups for individual records, perhaps a text file is enough. However, if you're doing anything more than this than a database is the way to go as it's sort of what they were intended for.

You could always implement both situations and profile which was faster, as this would be the pragmatic way to determine it in your environment and usage.


I suggest using SQL it is more flexible and optimized for that purpose especially for searching, inserting, updating. you can still however use file read/write as a cache system. many times you don't need to lookup the same information on every page visit. this is when you can cache the pages or just the data, and only update the cache each xx seconds/minutes/hour depend on your site.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜