« 像安装windows应用程序那样安装ubuntu | Main | 公众质疑:电话欠费的责任全在消费者吗 »

优化表

MySQL拥有一套丰富的类型。你应该对每一列尝试使用最有效的类型。
ANALYSE过程可以帮助你找到表的最优类型:SELECT * FROM table_name PROCEDURE ANALYSE()。
对于不保存NULL值的列使用NOT NULL,这对你想索引的列尤其重要。
将ISAM类型的表改为MyISAM。
如果可能,用固定的表格式创建表。
不要索引你不想用的东西。
利用MySQL能按一个索引的前缀进行查询的事实。如果你有索引INDEX(a,b),你不需要在a上的索引。
不在长CHAR/VARCHAR列上创建索引,而只索引列的一个前缀以节省存储空间。CREATE TABLE table_name (hostname CHAR(255) not null, index(hostname(10)))
对每个表使用最有效的表格式。
在不同表中保存相同信息的列应该有同样的定义并具有相同的列名。

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on April 28, 2007 6:03 PM.

The previous post in this blog was 像安装windows应用程序那样安装ubuntu.

The next post in this blog is 公众质疑:电话欠费的责任全在消费者吗.

Many more can be found on the main index page or by looking through the archives.

Creative Commons License
This weblog is licensed under a Creative Commons License.