Decepti0n Posted April 1, 2007 Posted April 1, 2007 MySQL 1. Use the COUNT modifier to check the table headers, and return the number of entries, than loading the whole info into an array and using mysql_num_rows() 2. Always use MySQL to do simple maths, such as totals, averages. It has built in functions just for this 3. Never load more than you need. If you only need the users name, don't do SELECT * FROM users, just select the name 4. Don't cram your table with useless columns. Having two columns for energy isn't necessary. Use one, have it as '50:100' (50% energy), and use PHP's explode() function to get the two values 5. If, like step 4, you use this a lot, use MySQL's SUBSTRING_INDEX function to do things such as finding users with only 40 energy 6. Reduce your server load by optimizing your queries, and save money on that dedicated server! 7. ALWAYS construct your own database class, and time your queries. You can use microtime() before and after your mysql_query() function, to see how long the query took. Try and record as much info as possible to be able to optimize further 8. As I said, ALWAYS check ALL input into the database 9. Don't use values such as 5 if you're checking something like days old, use the timestamp recorded when they sign up to compare it to the current time, and save another column 10. Don't store everything in the database. Some things, like IP bans can be stored in files, same as other things like if the game is shut down. Doing this reduces the amount of queries to the MySQL server, even if they aren't logged in. Similarly, you can store announcements etc in a text file, saving db calls on the login pages. And now i'll go die for bbcode abuse Quote
Vorlen Posted April 1, 2007 Posted April 1, 2007 Re: More fun Hot shit i can't wait until the permissions are fixed I'll have to agree 100%. Hey, I think I might add to this topic soon. :) Will edit this post if I do. Quote
oxidati0n Posted May 13, 2007 Posted May 13, 2007 Re: More fun Nice contribution and very descriptive/understandable. Thumps Up! ;) Quote
stryker Posted May 15, 2007 Posted May 15, 2007 Re: More fun ty deathstar that will help alot for ver2.0 of my game thx again +1 Quote
monbster Posted June 9, 2007 Posted June 9, 2007 Re: More fun 7. ALWAYS construct your own database class, and time your queries. You can use microtime() before and after your mysql_query() function, to see how long the query took. Try and record as much info as possible to be able to optimize further Nice, very informative! Can anyone explain more what this means? How does one "construct a database class"? Thanks Quote
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.