You are here: mysql-question « PHP Programming Language « IT news, forums, messages
mysql-question

Posted by ojorus on 08/04/06 12:00

Hi!
My company make several flash-based games, and I use php to communicate with
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 place
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)

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 million
records, the query is just too heavy for the mysql-server, and it breakes
down.

So my question is: Are there any better ways of getting a player's place?

Ole Johan, Norway

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация