Pages are slow to load

We have a strange situation.
Recently, the pages have been loading very slowly, sometimes taking up to 9 seconds. The same in the frontend or backend, especially in the product list.
The hosting people blame bots, the platform, memory/cpu overruns, although there has been no update for several months.
Using the &debug parameter, I found a SQL that takes a very long time. The SQL command is the one that returns the product list.
Our site is for online sales of toners and ink cartridges. The specific thing is that we have 1500 products so far but we have 4500 categories (printers) and the products_categories table has over 30000 lines.

I identified a join in the source code (app\functions\fn.products.php) that could be the cause:

$categories_join = db_quote(
        ' INNER JOIN ?:products_categories as products_categories ON products_categories.product_id = products.product_id' .
        ' INNER JOIN ?:categories ON ?:categories.category_id = products_categories.category_id' .
        ' ?p' .
        ' ?p',
        $category_avail_cond,
        $feature_search_condition
    );

I believe that this can be improved to avoid generation of 45 millions lines to group and sort.

What is your CS-Cart version? CS-Cart should handle this amount of data easily.

Version is 4.18.3. The hosting guys finally solved it.
They were blaming cs-cart but now that SQL that took 12 seconds now takes 0.69 seconds.
However, having experience in SQL, I still believe that that SQL should be optimized for the case where there are no other filters on categories. For example, if you add ’ and products_categories.link_type = “M” ’ to the join condition, the execution time drops to 0.08 seconds. But that’s because we have 30k lines in the products_categories table. For those who sell consumables, it’s something common.

2 Likes

could you please write here more details about how they resolved?!

The hosting team response:

The situation came from the limits applied by Cloudlinux even though they were displayed correctly and the situation could not be easily identified as it was a bug in a cloudlinux utility. The problem should not be repeated as we have taken the necessary measures in this regard.

We installed the full page cache addon too.

Glad to hear it is solved. Could you please share thoughts on the full page cache addon?

Pagespeed Insights shows 0.8 seconds.