I'm looking for the best solution to store the ettings for a website, like the limit of posts for users, limit of users online, ranks, min. number of posts to be able to do something. Like here, if you're new you can't thumbs up/down a post, or whatever, so how would you store all of these? I thought of creating a table with constants in mysql but i think it's not the best solution to add a new mysql query on every page refresh.
+1
A:
Why not? After all, MySQL can handle a large number of requests and I've seen much more complex queries than checking access rights. A MySQL query is a query to a file just like checking an INI file, but optimized. I'm guessing that if you don't expect a huge amount of traffic, you'll be fine with a database.
Here it's a matter of preference. I prefer to do this in MySQL because I don't like to parse files and find querying a database easier. Also, editing rows is easier than changing values in a text file.
I'd say your first thought was spot-on. Put constants into a database.
Jan Kuboschek
2010-06-27 15:24:25
Ok, will use mysql, i wanted to make sure it's fine, i thought about this problem because there are already a lot of important mysql queries that i have to make at every page refresh.
Supyxy
2010-06-27 15:47:11
Try and see if you can consolidate some. Depending on what information you're working with, in some cases, if you're working with data that is not expected to change at runtime you may want to consider storing the data in the session to avoid a few queries or redundant querying.
Jan Kuboschek
2010-06-27 16:02:20
If you are still concerned about MySQL performance, you may want to think about how you would scale out the database layer. First, you should think about caching queries using memcached. If there are no opportunities to cache content (ie, every query is specific to a user, content on the page is extremely dynamic.), then you should consider using replication to support more reads from the database layer.
Chris Henry
2010-06-27 16:09:55