Motivation example: I have a table containing "persons". A person tuble is (id,name,value). I need to return the 10 riches (as in, "most valueable") persons. Atm. im using the following query:
Then I use a for(i=1;i<=10;i++) loop. I get the wanted result, but my problem is that this will be pretty ineffective if I have 100000000 records in my DB.
Does anyone have any ideas or suggestions?
Please note, that I do not have any other tables in my DB. I thought about making a table "rank" containing a "rank" and the value.. the problem is, that with this solution I have to sort the table everytime I update a persons value.
Edit: The persons value will be updated more often, than one wants to get the top 10.