A
A
Alexander2018-11-21 19:39:36
MySQL
Alexander, 2018-11-21 19:39:36

How to stop the "growth" of b_sale_viewed_product in Bitrix 17?

Greetings!
In general, the site on Bitrix is ​​version 17 with a database weight of 17! gigabyte. The main (but not the only) problem is the table "b_sale_viewed_product" (13GB).
Judging by the site visit logs (server access_log), Yandex bot traverses the site throughout the day and indexes links. At this time, Bitrix writes all visited URLs to this table. Speed ​​~ 30 records per table/sec.
In the site settings, parameters have already been set that limit the amount of everything in general, while nothing was deleted from the database. The agent responsible for cleaning is present, but does not automatically work. How to kick it "manually", I do not know.
Question? How can I limit the write to this table so that it is within reason?
Help out, guys (and girls, there are probably those :)
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Gritsuk, 2018-11-21
@Alexandros96

Perhaps in the settings of the IM module there is not an adequate storage time for viewed products.
Also try clearing the table and see how quickly it will fill up again.
https://thisis-blog.ru/problema-razdutiya-tablic-b...
You can generally turn off saving data to this table in the MI module. The setting is called "Save viewed catalog items"

P
Pavel, 2018-11-21
@PavelMonro

This table stores the viewed products of users.
In the settings of the "Online store" module, it is possible to change the "Storage time of viewed products (days)" and "Maximum number of viewed products of the user".

Reduce storage time accordingly.
The function that is responsible for clearing the table:
public function _ClearViewed()
{
    global $DB;
 
    $viewed_time = COption::GetOptionString("sale", "viewed_time", "90");
    $viewed_time = IntVal($viewed_time);
 
    $strSql =
        "DELETE ".
        "FROM b_sale_viewed_product ".
        "WHERE TO_DAYS(DATE_VISIT) < (TO_DAYS(NOW()) - ".$viewed_time.") LIMIT 1000"; $db_res = $DB->Query($strSql, false, "File: ".__FILE__."
Line: ".__LINE__);
 
    return true;
}

Those. in fact, you can directly call the code in the database

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question