zoukankan      html  css  js  c++  java
  • Magento database maintenance

    Overview
    This article examines the various ways to maintain an efficient Magento database, even when large in size.

    Magento does many things well, but maintaining an efficient database is not one of them. Having many products is a good reason to have a large database. Sadly, this is not the only way your database can become large and sluggish. Maintaining the database through log cleaning can result in a dramatic improvement in site performance and latency. This guide explains how to optimize a large and potentially inefficient Magento database.

    Attention: Always backup your data before performing any operations on the database.

    Log cleaning

    Magento maintains several tables for logging. These tables log things such as customer accesses and frequently-compared products. Magento has a mechanism for cleaning these logs regularly, but unfortunately, this feature is disabled by default and most customers do not enable it. There are three ways to clean out these tables: via log cleaning in the Magento Admin, via log.php in the ../shell directory, and manually via phpMyAdmin or MySQL client.

    The following tables are managed by Magento's log cleaning function:

    log_customer
    log_visitor
    log_visitor_info
    log_url
    log_url_info
    log_quote
    report_viewed_product_index
    report_compared_product_index
    report_event
    catalog_compare_item

    Log cleaning via administrator interface

    1. From the Magento administrator interface, go to System > Configuration.

    2. In the left menu under Advanced, click System.

    3. Under Log Cleaning, change Enable Log Cleaning to Yes and configure the Save Log for 15 days:

    4. Click Save Config.

    Log.php

    You can either configure the shell utility log.php  as a cron job or run manually to clean on-the-fly. 

    1. From the Magento root directory, type the command:

     php -f shell/log.php clean

         2.  Use the –days switch to specify how many days of history to save.

    Manual cleaning via phpMyAdmin

    This is the most efficient way to clean the logs for those more comfortable working with databases. It is faster than the built-in Magento tools and it allows you to clean other tables not included in those tools. This procedure will consolidate the data inside those tables, often decreasing database size by as much as 95% and greatly reducing query times.

    1. Open the database in phpMyAdmin via the SiteWorx control panel.

    2. In the right frame, select the check box for the following tables:

      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
      report_viewed_product_index
      report_compared_product_index
      report_event


    3. At the bottom of the page, click the drop-down box With Selected and select Empty.

    4. A confirmation screen will appear. Click Yes. This will truncate all of the selected tables.

    5. Click the Structure tab at the top of the page.
    6. Select the same tables as you did in step 2, then under the With Selected drop-down menu, select Optimize.

    Regular maintenance

    It is not unusual to see 2GB+ databases decrease their size by 75% after cleaning the logs. It is therefore critical to regularly perform this sort of maintenance, particularly if your time-to-first-byte latency begins increasing and you have already implemented the other performance tweaks.  

    - See more at: http://docs.nexcess.net/article/magento-database-maintenance.html#sthash.VQEtkAE8.dpuf

  • 相关阅读:
    阿里面试后的问题总结
    Spring IOC源码实现流程
    Spring Aop源码分析
    SpringCloud的分布式配置及消息总线
    阿里java编码规范考试总结
    压缩文件的压缩时候中文乱码码
    mybatis的时间比较 xml 及不解析<=的写法
    批量插入一张表的数据,并且生成不同的uuid 字符截取 批量更新 去除重复数据
    Redis集群的搭建
    Python 之 基础知识(二)
  • 原文地址:https://www.cnblogs.com/free3649/p/4070241.html
Copyright © 2011-2022 走看看