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

时间: 2024-08-27 04:19:42

Magento database maintenance的相关文章

第24/24周 数据库维护(Database Maintenance)

哇哦,光阴似箭!欢迎回到性能调优培训的最后一期.今天我会详细讲下SQL Server里的数据库维护,尤其是索引维护操作,还有如何进行数据库维护. 索引维护 作为一个DBA,数据库维护是你工作中非常重要的一部分,让数据库获得最佳性能.一个SQL Server数据库就像一辆车:它需要经常的检查来保证运行没有问题,副作用,且拥有最大可能的性能.SQL Server数据库最重要的部分是它的索引及其对应的统计信息对象.SQL Server运行一段时间后会有索引碎片,统计信息必须更新,这样的话查询优化器才可

How to optimize Magento performance

OverviewThis guide demonstrates how to optimize Magento performance. Most optimizations will work with any version of Magento. Those intended for specific versions will be indicated as such. Tweak .htaccess The default .htaccess file that comes with

Magento中直接使用SQL语句

原理: magento是基于Zend Framework的,所以底层用的还是zend的zend db 在文件app/code/core/Mage/Catalog/model/Resource/Eav /Mysql4/Config.php 中追踪到下面的函数 getAttributesUsedInListing() /*** Retrieve Product Attributes Used in Catalog Product listing** @return array*/public fun

Oracle 11g Articles

发现一个比较有意思的网站,http://www.oracle-base.com/articles/11g/articles-11g.php Oracle 11g Articles Oracle Database 11g: New Features For Administrators OCP Exam Articles Oracle Database 11g Release 1: Miscellaneous Articles Oracle Database 11g Release 2: Misc

分布式系统领域有哪些经典论文

0 个回答 默认排序 知乎用户 机器学习 话题的优秀回答者 901 人赞同了该回答 谢邀!五一快乐!分布式系统在互联网时代,尤其是大数据时代到来之后,成为了每个程序员的必备技能之一.分布式系统从上个世纪80年代就开始有了不少出色的研究和论文,我在这里只列举最近15年范围以内我觉得有重大影响意义的15篇论文(15 within 15).1. The Google File System: 这是分布式文件系统领域划时代意义的论文,文中的多副本机制.控制流与数据流隔离和追加写模式等概念几乎成为了分布式

50种方法优化SQL Server数据库查询(转载)

原文地址:http://www.cnblogs.com/zhycyq/articles/2636748.html 查询速度慢的原因很多,常见如下几种: 1.没有索引或者没有用到索引(这是查询慢最常见的问题,是程序设计的缺陷) 2.I/O吞吐量小,形成了瓶颈效应. 3.没有创建计算列导致查询不优化. 4.内存不足 5.网络速度慢 6.查询出的数据量过大(可以采用多次查询,其他的方法降低数据量) 7.锁或者死锁(这也是查询慢最常见的问题,是程序设计的缺陷) 8.sp_lock,sp_who,活动的用

[转载] nosql 数据库的分布式算法

原文: http://juliashine.com/distributed-algorithms-in-nosql-databases/ NoSQL数据库的分布式算法 On 2012年11月9日 in 也为稻粱故, by Juliashine 本文译自 Distributed Algorithms in NoSQL Databases 系统的可扩展性是推动NoSQL运动发展的的主要理由,包含了分布式系统协调,故障转移,资源管理和许多其他特性.这么讲使得NoSQL听起来像是一个大筐,什么都能塞进去

SQL Server专家的10个秘诀(翻译加注解)

当你点开这篇文章的时候,如果觉得没有读下去的必要,也希望你能拉到最后看看那几行字! 原文出处:https://technet.microsoft.com/en-us/magazine/gg299551.aspx 译者注: 本文主要以翻译为主,但由于工作经历,译者也有一些自己的看法和心得,并且不打算完全照搬直译,期间过滤了一些本人觉得无关紧要的信息,如果读者觉得看的别扭,可以看原文. 这篇文章可能已被广为流传和翻译,但是只要本人觉得有必要的,都会翻译或者直接公布原文,因为我相信总有人没有发现.并且

记一次数据库调优过程(IIS发过来SQLSERVER 的FETCH API_CURSOR语句是神马?)

记一次数据库调优过程(IIS发过来SQLSERVER 的FETCH API_CURSOR语句是神马?) 前几天帮客户优化一个数据库,那个数据库的大小是6G 这麽小的数据库按道理不会有太大的性能问题的,但是客户反应说CPU占用很高,经常达到80%~90% 我检查了任务管理器,确实是SQLSERVER占的CPU 而服务器的内存是16G内存,只占用了7G+ 客户的环境: Windows2008R2 SQLSERVER2005 SP3 64位 企业版 服务器内存:16G CPU:8核 RDS:阿里云主机