MySQL Statistical information

Source: Internet
Author: User

Introduction

The purpose of database maintenance statistics is to optimize the performance of the optimization, first of all the statistics are based on the index, if the table is not indexed then the table has no statistics.

How the system collects statistical information

First, manual

1. Execute Analyze Table

The InnoDB and Mysiam storage engines can collect the statistics of the table by executing "Analyze table tablename", unless the execution plan is inaccurate, and do not do so easily, if it is a large table, the operation will affect the performance of the table.

Second, automatic trigger

The following behavior automatically triggers the collection of statistical information

1. The first time you open a table

2. When the table modifies more than 1/6 or 2 billion rows

3. When a new record is plugged in

4. When you execute show index from tablename or execute Show table, query Information_schema.tables\statistics

Three, open parameter Innodb_stats_on_metadata

Access to the following table after the parameter innodb_stats_on_metadata is turned on also triggers the collection of statistics

Statistics for InnoDB tables are automatically collected when you access the following tables

Information_schema. Tablesinformation_schema. Statisticsinformation_schema. Partitionsinformation_schema. Key_column_usageinformation_schema. Table_constraintsinformation_schema. Referential_constraintsinformation_schema.table_constraints

Parameter description:

innodb_stats_sample_pages: the number of pages sampled each time the statistics are collected , by default

Innodb_stats_persistent: By default, the statistics generated by the Analyze table are saved on disk until the next analyze table , which avoids the dynamic update of statistics. The stability of the implementation plan was ensured, and the resources needed to collect statistics were also saved for the large scale;

Summary

Note:

pursuer.chen

Blog:http://www.cnblogs.com/chenmh

This site all the essays are original, welcome to reprint, but reprint must indicate the source of the article, and at the beginning of the article clearly give the link.

Welcome to the exchange of discussions

MySQL Statistical information

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.