Magento 2 - Table report_viewed_product_index slowed down after so many page views
-
17-03-2021 - |
Domanda
The table report_viewed_product_index
stores the page visits of every users against their user ids.
After 1 year of user, when users have huge data of page views product detail page is slower for some users.
Any kind of help would be highly appreciated.
Edit
I have enabled query log on server, and observed this:
- When I open product page there are 6048 queries
- After truncating table
report_viewed_product_index
the queries on product page are just 820 - Note: In both cases, query count on
report_viewed_product_index
are just 5
Soluzione
I have done some test cases on data to observed behavior of slow loading.
I have figured out that when some old customers that has more browsing data is experiencing slow page load. So I have no other option but to TRUNCATE
this table.
Here are the test cases that I have performed:
Test Case 1:
- full records in report_viewed_product_index table
- Customer logged in
- Queries on product page: 6052
- Queries on table report_viewed_product_index: 5
Test Case 1 (Repeat):
- full records in report_viewed_product_index table
- Customer logged in
- Queries on product page: 6149
- Queries on table report_viewed_product_index: 5
Test Case 2:
- full records in report_viewed_product_index table
- Customer not logged in
- Queries on product page: 546
- Queries on table report_viewed_product_index: 5
Test Case 2 (Repeat):
- full records in report_viewed_product_index table
- Customer not logged in
- Queries on product page: 546
- Queries on table report_viewed_product_index: 5
Test Case 3:
- empty records in report_viewed_product_index table
- Customer logged in
- Queries on product page: 1045
- Queries on table report_viewed_product_index: 5
Test Case 3 (Repeat):
- empty records in report_viewed_product_index table
- Customer logged in
- Queries on product page: 850
- Queries on table report_viewed_product_index: 5
Test Case 4:
- empty records in report_viewed_product_index table
- Customer not logged in
- Queries on product page: 694
- Queries on table report_viewed_product_index: 5
Test Case 4 (Repeat):
- empty records in report_viewed_product_index table
- Customer not logged in
- Queries on product page: 546
- Queries on table report_viewed_product_index: 5
Altri suggerimenti
According to the answer of Shoaib Munir:
You need to truncate report_viewed_product_index
table with this command
TRUNCATE report_viewed_product_index
User experience is more important than reports for management :)
So it is better to truncate this table and get view from google analytics