How to Optimize your Magento Database

Updated on Mar 8, 2019

Maintain and cleaning your old Magento Cache and Log records can greatly improve your Magento Database performance. Very often Magento database grows big in size due to large log tables and it might be a good idea to regularly perform a maintenance clean up.

To achieve this you can create a small script to be executed on regular bases. The exact script code can be found here.

To Optimize your Magento Database, you need to:

step

Clean Log Tables

'adminnotification_inbox',
'aw_core_logger',
'dataflow_batch_export',
'dataflow_batch_import',
'log_customer',
'log_quote',
'log_summary',
'log_summary_type',
'log_url',
'log_url_info',
'log_visitor',
'log_visitor_info',
'log_visitor_online',
'index_event',
'report_event',
'report_viewed_product_index',
'report_compared_product_index',
'catalog_compare_item',
'catalogindex_aggregation',
'catalogindex_aggregation_tag',
'catalogindex_aggregation_to_tag'
step

Clean Old Cache and Log Files

The second option clean old logs and cache files as well as pearlib downloads and cache in the following directories:

'downloader/.cache/',
'downloader/pearlib/cache/*',
'downloader/pearlib/download/*',
'var/cache/',
'var/locks/',
'var/log/',
'var/report/',
'var/session/',
'var/tmp/'

To perform the any of the above tasks simply create a file called cleanup.php in your Magento home directory via FTP or your cPanel → File Manager. You can copy the content of the file from this example.

When you have the file placed in your Magento folder with the copied contend you will need to access the file via:

http://www.domain.com/cleanup.php?clean=log         --clean log tables
http://www.domain.com/cleanup.php?clean=var         --clean cache files

Remember to change "www.domain.com" with your actual domain name.

If you would like to have this executed on regular bases you may set a cron job via your cPanel → CronJobs following our cPanel Tutorial on How to Create CronJobs. The exact command should be:

curl -s -o /dev/null http://www.domain.com/cleanup.php?clean=log
curl -s -o /dev/null http://www.domain.com/cleanup.php?clean=var
On this page...

    Magento Hosting

    • Free Installation
    • 24/7 Magento Support
    • Free Domain for life
    • Hack-free Protection
    • Fast SSD Storage
    • Free CloudFlare CDN
    • Free Magento Transfer
    • Immediate Activation
    View More