I am writing backend code in PHP where there are client requests and I have to show them a collection of users based on priority amongst many thousand users.
My Problem is this: since the queries are too heavy requiring a lot of inner joins and comparisons, that will make the code very slow and the response will consume a lot of time.
Can you suggest a method by which I can accumulate all the users, perform all queries and calculations without affecting the request and response times?
You can try a technique called Materialized views, i.e. doing precomputations into some tables containing agregates and using the agregates to speed up your online query. On the other hand, if the data you’re basing your computation on, is changing often, this technique won’t be of much help.
Look here for some more details on the subject: http://www.fromdual.com/mysql-materialized-views