I have a big user table (3M), of structure:
age (int)
country (FK)
city (text)
gender (text)
active (bool)
My objective is to run a search finding 15 users of given age area, gender, city and country (favouring active users).
I'm having two issues, due to the size of the table:
Even with indexing, it takes a long time (a couple hundred miliseconds)
Results must differ each time the query is ran. Currently I execute query with LIMIT 30 and just get random 15 results from it, but the 30 results are always the same. Whole table is too big to do shuffling.
Is there some commonly used solution for overcoming similar issues?
The database server is MySQL, implementation in Django. I also have access to Redis cache.