I could really use some help optimizing a table on my website that is used to display rankings. I have been reading a lot on how to optimize queries and how to properly use indexes but even after implementing changes I thought would work, little improvement can be seen. My quick fix has been simply to use only the top 100,000 rankings (updated daily and stored in a different table) to improve the speed for now, but I really don't like that option.
So I have a table that stores the information for users that looks something like:
table 'cache':
id (Primary key)
name
region
country
score
There are other variables being stored about the user, but I don't think they are relevant here as they are not used in the rankings.
There are 3 basic ranking pages that a user can view:
A world view:
SELECT cache name,region,country,score FROM cache ORDER BY score DESC LIMIT 0,26
A region view:
SELECT name,region,country,score FROM cache WHERE region='Europe' ORDER BY score DESC LIMIT 0,26
and a country view:
SELECT name,region,country,score FROM cache WHERE region='Europe' AND country='Germany' ORDER BY score DESC LIMIT 0,26
I have tried almost every combination of indexes I can think of to help alleviate work for the database, and while some seem to help a little bit I can't find one that will only return 26 rows for both the region and country queries(with simply an index on 'score' the world rankings are blazing fast).
I feel like I might be missing something basic, any help would be much appreciated!
Little extra info: the cache table is currently around 920 megabytes with a little more than 800,000 rows total. If you could use any more info just let me know.