Mysql Database optimization Tool PROCEDURE analyse

Source: Internet
Author: User
Tags mysql database

PROCEDURE analyse gives suggestions for optimizing each column of an existing table by analyzing the results of the select query.
The syntax for PROCEDURE analyse is as follows:
SELECT ... From ... WHERE ... PROCEDURE analyse ([max_elements,[max_memory]])

Max_elements (default value 256) analyze the maximum number of different values to look for when each column has a different value.
Analyze also uses this value to check whether the optimized data type should be an enum, if the number of different values in the column exceeds the
The max_elements value enum is not a data type that is recommended for optimization.
Max_memory (default 8192) analyze the maximum amount of memory that may be allocated when finding all the different values for each column

The code is as follows Copy Code

Eg:select * from Web_member procedure analyse (1)

Sample Program

1

The code is as follows Copy Code
SELECT * From students procedure analyse ();
SELECT * From students procedure analyse (16,256);

The second statement requires procedure analyse () not to suggest that there are more than 16 values or enum types that contain more than 256 bytes, and that the output can be long if there are no restrictions;

2

The code is as follows Copy Code

------------------------------------------------------------------------------------
mysql> DESC user_ Account
+-----------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+------------------+------+-----+---------+----------------+
| USERID | int (a) unsigned | NO | PRI | NULL | auto_increment |
| USERNAME | varchar (10) | NO | | NULL | |
| Passsword | varchar (30) | NO | | NULL | |
| GroupName | varchar (10) | YES | | NULL | |
+-----------+------------------+------+-----+---------+----------------+
4 rows in Set (0.00 sec)

Mysql> SELECT * from User_account PROCEDURE analyse (1) G;
1. Row ***************************
Field_name:ibatis.user_account. Userid
Min_value:1
max_value:103
Min_length:1
Max_length:3
empties_or_zeros:0
nulls:0
avg_value_or_avg_length:51.7500
std:50.2562
Optimal_fieldtype:tinyint (3) UNSIGNED not NULL
2. Row ***************************
Field_name:ibatis.user_account. USERNAME
Min_value:dfsa
Max_value:lmeadors
.........................................................

---------------------------------------------------------------------------------------
We can see the Analyze analysis Ibatis.user_account from the first line output. The UserID column has a minimum value of 1, a maximum value of 103, a minimum length of 1,
The maximum length 3 ..., and gives the optimization suggestion of changing the field: It is recommended that the data type of the field be changed to tinyint (3) UNSIGNED not NULL.

Related Article

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.