Cleaning Magento Logs in Database

Magento has a very nice script on the shell directory called “log.php”. You can do many things with it, these are the 2 most interesting ones for me:

Wiew the log data’s size

$ php log.php status
-----------------------------------+------------+------------+------------+
Table Name                         | Rows       | Data Size  | Index Size |
-----------------------------------+------------+------------+------------+
log_customer                       | 84.83K     | 4.73Mb     | 3.69Mb     |
log_visitor                        | 2.22M      | 185.83Mb   | 0 b        |
log_visitor_info                   | 2.30M      | 368.44Mb   | 0 b        |
log_url                            | 7.92M      | 429.72Mb   | 471.38Mb   |
log_url_info                       | 8.37M      | 1.41Gb     | 0 b        |
log_quote                          | 10.70K     | 1.33Mb     | 0 b        |
report_viewed_product_index        | 1.59M      | 93.96Mb    | 329.17Mb   |
report_compared_product_index      | 7          | 16.38Kb    | 81.92Kb    |
report_event                       | 1.82M      | 114.98Mb   | 271.50Mb   |
catalog_compare_item               | 7          | 16.38Kb    | 81.92Kb    |
-----------------------------------+------------+------------+------------+
Total                              | 24.31M     | 2.61Gb     | 1.08Gb     |
-----------------------------------+------------+------------+------------+

Clean log data based on a number of days:

$ php -f log.php clean --days 30

Leave a Reply

Your email address will not be published.