On one single page, I do have about 100 queries like
$sQuery = "SELECT *
FROM `users`
HAVING `team` = $team
AND `group` = $group AND male = 1 AND `team1` > 0 AND `team2` > 0 AND status LIKE 'movies'";
$rResult = $pdo->query($sQuery)->fetchAll();
$results = count($rResult);
running as a cronjob to save the results of those queries in another table.
The users
table has about 2.100.000 rows. Yes, 2.1m and growing but slowly growing. The results of each query have between 0 and 40 rows each, not more. Now my question: I guess there is a better way to get the results and save them to another table, so do you have any suggestions? Surprisingly, the cronjob takes too long to load and of course, freezes very often.
I have used prepared statements before, but those were even slower. At least I had the feeling. I hope you can help me here. Thank you very much!