I stand at a crossroads, I do not know what to choose, tell me, please.
There is a database with a table of products and some of their properties in separate tables, and more precisely:
good (~2k ΠΠ°ΠΏΠΈΡΠ΅ΠΉ) catalog (~50 Π·Π°ΠΏΠΈΡΠ΅ΠΉ) form (4 Π·Π°ΠΏΠΈΡΠΈ) type (~100 Π·Π°ΠΏΠΈΡΠ΅ΠΉ) color (10 Π·Π°ΠΏΠΈΡΠ΅ΠΉ) sostav (5 Π·Π°ΠΏΠΈΡΠ΅ΠΉ) sizes (~200) width (~50) Accordingly, in each of these 11 (including the <-> relationship tables) tables, the Nth number of columns. In total, about 150 from all tables.
The question is how best to do it:
- 6 different queries with only the necessary JOIN and columns (1 for a selection of products and 5 for displaying filters) + JOINs and conditions if filters and / or sorting are selected
- The stored procedure from the query with all JOIN and all columns and the further processing of all this porridge in PHP (not at all optimal, in my opinion, but you never know)
- 1 request to the temporary table and further samples from it (still long, because the complete request itself is executed from 2 to 20 seconds) + if I'm not mistaken, a temporary table will be created for each open connection separately. Respectively 20 simultaneous users - 20 temporary tables from ~ 300k rows
- Create a table containing the result of sampling all JOINs, with a composite PK for all PK of incoming tables and indexes on the required columns and update it periodically. Say once per hour / 5hours / day.
- Option 4, but updating the data on the triggers (I donβt know yet whether it is possible in the trigger), the product data is not updated frequently, but triggers are called many times at a time ... Add 1 product to associate it with 5 sizes - 6 calls trigger, at least ... + types + colors ... (a manager can change / add 10-50 products per day)
- What is a normal option?
In any case, the minimum set of JOIN that should be in all queries:
goods - ΡΠΎΠ±ΡΡΠ²Π΅Π½Π½ΠΎ, ΡΠΎΠ²Π°ΡΡ catalogs - ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΠΈ ΡΠΎΠ²Π°ΡΠΎΠ² (Π΄Π»Ρ ΠΏΡΠΎΠ²Π΅ΡΠΊΠΈ Π²ΠΊΠ»/Π²ΡΠΊΠ») size_type_1 - ΡΠ°Π·ΠΌΠ΅ΡΡ (Π΄Π»Ρ ΠΏΡΠΎΠ²Π΅ΡΠΊΠΈ ΠΎΡΡΠ°ΡΠΊΠΎΠ²) Also, in each request there will be a calculation Π² Π½Π°Π»ΠΈΡΠΈΠΈ / Π½Π΅Ρ Π² Π½Π°Π»ΠΈΡΠΈΠΈ + HAVING according to this calculation for filters (there should be only actual data)
That such a problem arose before me. It seems to be all in detail, as I could describe. I really hope for your help :)

