Answer the question
In order to leave comments, you need to log in
Complex fetch from MySQL?
Such a task. There is a kind of ... calculator. In it, roughly speaking, 200 positions. Calculator for calculating services for a certain type of work. Prices for services should be generated automatically, according to the data entered by the register. users. That is, after registration, they get the opportunity to fill in "their" calculator, which is saved in a separate table (each user has their own table with values). There is a cron that every night, in theory, will get all-all-all values from the database, from each table, for each category (i.e., each table can contain 200 records, and if there are at least ten users, this is already 2000 requests) just for the sake of choosing the highest value for a particular category. General view of such tables
------------------------------
| id | category_id | price |
...
| 234 | 156 | 52 |
| 235 | 157 | 12 |
...
--------------------
It turns out just an unrealistic load on the server. And among all the tables, of which there will be thousands, you need to select the maximum and minimum value for a specific category_id. Hope I explained clearly.
So far, the method is just hellish - I select all the tables with SHOW, go through them with foreachs, whils, pull out all the values, save them all in a separate array, and so on as many times as there are in the table database. As a result, two users took me about 185 ms and about a thousand requests passed. What to do? (
Thanks in advance!
Answer the question
In order to leave comments, you need to log in
Not very clear.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question