MySQL Data Size Increasing to 36 GB or More – Causes and Solutions

ce-1.8.1.0MySQL

Yesterday, my store completely down with this critical error

Can't connect to local MySQL server through socket '/tmp/mysql.sock'

I contacted hosting company, they said error is due to HDD is full and my mysql data is over 36 GB

and they also said 'core_cache' table have 26 GB data size

(Last week, when I dumb the database, I got 3 ~ 5 GB sql file)

enter image description here

While I'm checking, I found mysql data suddenly become 9 GB

enter image description here

So my store become work again since there is hdd space

When I check mysql data today, it is 14 GB few hour ago, and now it's 16 GB it keep increase the size

I think when my hdd become full due to the mysql size again , I will get critical error and store will be down

Can I know why mysql data is so big and keep increase, big size core_cache tables , what should I check..? or solution

( innodb_version | 5.6.19 )

Appreciate any answer or comments!

UPDATE – Most space is taken by index tables (like core_cache, core_url_rewrite, catalog_product_index_eav_idx and so on)

We have around 90,000 SKU products (group + simple)

Tables ! | Size in MB

m_core_cache | 8453.14 |

m_core_url_rewrite | 896.05 |

m_catalog_product_index_eav_idx | 280.88 |

m_catalog_product_entity_varchar | 231.56 |

Best Answer

Magento needs to have log_ table cleaning enabled, website traffic will build up a horrific amount of data in all the log_ tables. Two steps are needed:

  1. you must have a crontab entry to run cron.sh or cron.php at least every 15 minutes. This is the cron trigger that serves as the heartbeat for Magento's internal cron processes. Sample lines in crontab to run.

    */5 * * * * /bin/sh /absolute/path/to/magento/cron.sh

    or

    */5 * * * * /absolute/path/to/bin/php /absolute/path/to/magento/cron.php

  2. you must go to System->Config->Advanced->System to complete the Log Cleaning setup.

enter image description here

For manual cleaning, you can use the command line shell/ utilities. SSH into your document root and run:

php shell/log.php clean

Given the sheer quantity of junk it sounds like you have built up, expect it to error out with a memory error. You might try adding the --days switch and figure out how old your website is and slowly reduce the number so it's not trying to process so much at once.

php shell/log.php clean --days 360

The following will tell you the log tables status.

php shell/log.php status
-----------------------------------+------------+------------+------------+
Table Name                         | Rows       | Data Size  | Index Size |
-----------------------------------+------------+------------+------------+
log_customer                       | 3.34K      | 180.22Kb   | 98.30Kb    |
log_visitor                        | 46.52K     | 4.21Mb     | 0 b        |
log_visitor_info                   | 46.57K     | 8.40Mb     | 0 b        |
log_url                            | 82.49K     | 5.26Mb     | 5.26Mb     |
log_url_info                       | 84.05K     | 12.60Mb    | 0 b        |
log_quote                          | 527        | 49.15Kb    | 0 b        |
report_viewed_product_index        | 115.99K    | 6.83Mb     | 23.35Mb    |
report_compared_product_index      | 0          | 16.38Kb    | 81.92Kb    |
report_event                       | 79.56K     | 5.78Mb     | 16.20Mb    |
catalog_compare_item               | 0          | 16.38Kb    | 81.92Kb    |
-----------------------------------+------------+------------+------------+
Total                              | 459.04K    | 43.35Mb    | 45.07Mb    |
-----------------------------------+------------+------------+------------+
Related Topic