Answer the question
In order to leave comments, you need to log in
How to optimize the number of requests and organize data storage?
If very briefly. There is a small own CRM system (accounting for goods, etc.) on the basis of this system, a module was written (some similarity for CMS), so that the content manager would manage the site directly from CRM. Everything is written in php.
The database structure (in mySQL) is built in such a way that there is a page for the site. And this page has groups of properties (I describe it just approximately for an example, so as not to go into a detailed structure):
Answer the question
In order to leave comments, you need to log in
It is necessary to divide the formation of the page into stages - getting a list of blocks - getting data for blocks (here we group by block types and for each we remake data getting into a mass one through where id in (...)) and return an associative array with the key = id. Well, rendering cards with the output of already received data. Thus, to form N product cards, you will still need three requests.
1. Request to pages - selection of the necessary data, selection of the ID of the results.
2. Request to props_group WHERE page_id IN (), extracting the ID of the results.
3. Query props_value WHERE props_group_id IN ().
4. Gathering the received information into a pile and transferring this pile to rendering with a template.
0. And no JSON.
That's right - do not start an entity-value system anywhere, do you really have new data types appearing there and changing every day?
Store the values as expected - in tables and columns
, and that's not all
wrong in the cycle to interrogate the cards and make one request for each. you have a lot of objects of the same type on the page, you take a list of their id and load all the necessary data at once with one request.
if you don’t want to remake your props_value, add a column with the card ID to this table, then the backend will be able to load all the necessary values \u200b\u200bat once with one request, and already in memory you can quickly collect anything from them
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question