MySQL Forums
Forum List  »  Optimizer & Parser

Help Optimizing My SELECT Query
Posted by: gooey graphics
Date: July 19, 2010 12:54PM

I need help making my query more efficient. My host just suspended me because I'm using too many resources on the server and affecting other customers.

My problem is, I have a db with approx. 10k rows. something like this:

userid score
user1 14000
user99 300
...


I need to select the top 500 scores and return 'userid' and 'score' columns.

The way I am doing it now (apologize can't login to my acct and get the command i'm using) is:

SELECT * from `players` ORDER BY 'score' ASC (something to that effect)

After researching i think LIMIT will work but i'm not sure if that will return the first 500 rows or the 'TOP' 500 rows???
How can I do this more efficiently instead of returning all 10k rows?



Edited 1 time(s). Last edit at 07/19/2010 12:56PM by gooey graphics.

Options: ReplyQuote


Subject
Views
Written By
Posted
Help Optimizing My SELECT Query
2847
July 19, 2010 12:54PM
1291
July 21, 2010 01:06PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.