Is there a way to clean up the Hikashop product database?

  • Posts: 91
  • Thank you received: 5
  • Hikashop Business
4 days 13 hours ago #371779

-- HikaShop version -- : 6.4,1
-- Joomla version -- : 5.4.5
-- PHP version -- : 8.2.30

My client's shop has been running for years now and the amount of products in HikaShop has grown steadily all that time. Right now the shop contains about 3600 products, many of which have 5 to 15 variants. Because of this my database is becoming quite large (currently around 1.2 GB), and this is starting to give memory issues on my server when doing things like product exports or generating a site map.
I have already asked the client to go though their products and delete any that are no longer needed, but this does not really fix the issue.
So my question is: are old products entries removed from the Hikashop database tables when they are deleted from the administrator console? And, if this is not the case, is there a way to clean up the product database, by removing any data that is no longer relevant?

Please Log in or Create an account to join the conversation.

  • Posts: 85581
  • Thank you received: 14006
  • MODERATOR
4 days 9 hours ago #371782

Hi,

3600*~10 variants is only less than 50 000 entries in the hikashop_product.
That's not what is eating your database memory. It shouldn't take more than a few MB. Normally, variants don't have a description and just use the description of their main product, and the description is the main thing eating the memory for a product entry.

The first thing to do is to open your PHPMyAdmin and check the number of entries for each table in the database and the size of each table. I would wager the problem is elsewhere, in another table.
For example, if you've been running HikaShop for years with the Email history plugin activated without a "number of days" set in its settings, the email log table in the database has been steadily growing without any cleanup of its data. The emails take quite a bit of space individually, so if you have hundreds of thousands of them, that could take a significant share of the pie.
It's been a while now that this setting has been added with it's default set to 30 days. But if you updated from an old version, it's possible that you still have that setting empty.

But it could be something else entirely. I'm just talking about the email history because that's something that happened to someone else in the past. Anyways, what to do next depends on what you find in the database.

Please Log in or Create an account to join the conversation.

  • Posts: 91
  • Thank you received: 5
  • Hikashop Business
3 days 16 hours ago #371798

Hi Nicolas,

Thank you fro your reply. As you suggested, I have done a database query for the number of rows and size in MB for each table in my database. I have attached a screenshot of the largest ones. I am not sure what to make of this and what I could do to reduce the size of some tables (if even possible). You were right that the products don't appear to be the problem. As you can see from the screenshot the largest tables are related to the cart, finder, links and email.

Attachments:
Last edit: 3 days 16 hours ago by Foxworks.

Please Log in or Create an account to join the conversation.

  • Posts: 85581
  • Thank you received: 14006
  • MODERATOR
3 days 12 hours ago #371799

Hi,

You have 500 MB of data for carts, with 2.3 millions carts in the database. Most of them must be spam, the rest, too old. Probably only a few dozen is even relevant. We implemented improvments recently against these, but these must be from before.
Empty the hikashop_cart and hikashop_cart_product tables to fix this.
You also have 900MB of data from the Joomla Smart Search. You can try to clear the index and try to reindex the search in the Smart Search component. Also, in the HikaShop Smart search plugin, there is a setting to index variants. Check that this is turned off before reindexing the data. That should eat a lot less memory.
You also have 100MB of emails, for a total of a bit more than 10K emails logged. I would recommend clearing the hikashop_email_log table and making sure the plugin is properly configured, as I was saying in my previous message.
The product and variant data is only 50MB in total. You can ignore it, that's not your problem, as I was expecting.

Please Log in or Create an account to join the conversation.

  • Posts: 91
  • Thank you received: 5
  • Hikashop Business
1 day 4 hours ago #371841

Hi Nicolas,

Thank you for the detailed reply. Can I simply empty the ikashop_cart, hikashop_cart_product, and hikashop_email_log by dropping all rows from those three tables in MyPHPAdmin? Or would that mess things up?

Last edit: 1 day 4 hours ago by Foxworks.

Please Log in or Create an account to join the conversation.

  • Posts: 85581
  • Thank you received: 14006
  • MODERATOR
19 hours 26 minutes ago #371842

Hi,

Yes, you can just drop all rows in these tables.
What that will do is that real users with a cart will loose their cart.
So, ideally, you want to do that when you know there are not many people connected to your website.

Please Log in or Create an account to join the conversation.

  • Posts: 91
  • Thank you received: 5
  • Hikashop Business
13 hours 3 minutes ago #371847

Thanks for the clarification. I have emptied those three tables. However, as soon as i did, I can see new entries popping up, even while my site is set to 'offline' in the global configuration.

Coincidentally (or actually probably not) I just received a warning from my webhost that there are an extreme number of requests to URLs containing /product/updatecart/add-1/. They say that this is malicious bot traffic.
Could these requests be causing the enormous amount of carts saved in the database? And, if so, is there a way to block these requests by bots going forward?

Please Log in or Create an account to join the conversation.

Time to create page: 0.065 seconds
Powered by Kunena Forum