MySQL利用procedure analyse()函數最佳化表結構_Mysql

來源:互聯網
上載者:User

簡介

procedure analyse()函數是MySQL內建的對MySQL欄位值進行統計分析後給出建議的欄位類型。

文法

procesure analyse(max_elements,max_memory)

max_elements

指定每列非重複值的最大值,當超過這個值的時候,MySQL不會推薦enum類型。

max_memory

analyse()為每列找出所有非重複值所採用的最大記憶體大小。

實戰演練

# 對t1表所有的列進行分析wing@3306>show create table t1;+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------+| Table | Create Table                                                                      |+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------+| t1  | CREATE TABLE `t1` ( `id` int(11) DEFAULT NULL, `name` varchar(16) DEFAULT NULL, `score` int(11) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 |+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------+1 row in set (0.00 sec)wing@3306>select * from t1 procedure analyse(4);+---------------+-----------+-----------+------------+------------+------------------+-------+-------------------------+-------------+--------------------------------+| Field_name  | Min_value | Max_value | Min_length | Max_length | Empties_or_zeros | Nulls | Avg_value_or_avg_length | Std     | Optimal_fieldtype       |+---------------+-----------+-----------+------------+------------+------------------+-------+-------------------------+-------------+--------------------------------+| wing.t1.id  | 1     | 200000  |     1 |     6 |        0 |   0 | 100000.5000       | 116099.2790 | MEDIUMINT(6) UNSIGNED NOT NULL || wing.t1.name | 000jxc6V | zzznmkcX |     8 |     8 |        0 |   0 | 8.0000         | NULL    | CHAR(8) NOT NULL        || wing.t1.score | 1     | 100    |     1 |     3 |        0 |   0 | 50.4889         | 28.8768   | TINYINT(3) UNSIGNED NOT NULL  |+---------------+-----------+-----------+------------+------------+------------------+-------+-------------------------+-------------+--------------------------------+3 rows in set (0.14 sec)

總結

以上就是關於MySQL中procedure analyse()函數的全部內容了,希望本文的內容對大家的學習或者工作能帶來一定的協助,如果有疑問大家可以留言交流。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.