Do you have a question? Post it now! No Registration Necessary. Now with pictures!
August 4, 2006, 1:29 pm
rate this thread
My company make several flash-based games, and I use php to communicate
mysql to provide highscore-lists.
My problem is this:
When I save a player's score in the mysql-table, I want to find which
the player got with his score (today). To get this I have tried two
different solutions, which both works, but are very ineffective: (The
Time-field is a DateTime type, and I have Score and Time as Indexes.
The Score-field is a DECIMAL (20,2))
1) SELECT COUNT(*) FROM table WHERE Score>=$score AND Time>CURDATE().
- or -
2) SELECT Score FROM table WHERE Score>=$score AND Time>CURDATE().
... $place = mysql_num_rows($result)
Both give the right result, but the problem is that when there are many
players playing at the same time, and the table consists of several
records, the query is just too heavy for the mysql-server, and it
So my question is: Are there any better ways of getting a player's
Ole Johan, Norway
Re: performance questions
Unfortunately, both those solutions must search the entire db looking for
'Score >= $score'... you probably need to divide your db into smaller tables
of score ranges so that the queries don't take as long:
well, you get the idea. Then just place some PHP logic to
INSERT/UPDATE/SELECT the $score into/from the proper table.
- » returning relevane of match queries as a percentage
- — Next thread in » MySQL Database Forum
- » Americanas.com SALDO de TVs Com at 80% de Desconto (29798)
- — Newest thread in » MySQL Database Forum