ITPub博客

首页 > 数据库 > MySQL > 提升MySQL性能值得借鉴的几个简易方法

提升MySQL性能值得借鉴的几个简易方法

原创 MySQL 作者:spaceair 时间:2005-09-08 16:18:41 0 删除 编辑
提升MySQL性能的几个简易方法,主要用于设计、开发阶段的借鉴。[@more@]1、Carefully choose attribute types and lengths.
仔细选择字段的类型与长度。
2、Use fixed-length attributes: try to avoid the types VARCHAR, BLOB, and TEXT.
使用固定长度的字段,尽量避免使用VARCHAR、BLOB、TEXT。
3、MySQL can't join tables using an index if the attributes are different types or (in some cases) have different lengths.
如果表的类型或长度不一致,MySQL在表连接时将无法使用索引。
4、Create a statistics table if aggregate functions such as COUNT( ) or SUM( ) are frequently used in queries that contain WHERE clauses and are on large tables.
对于包含where子句的查询和大的表,如果经常需要用到统计函数(如count、sum),最好创建对应的统计表。
5、If you're inserting large numbers of rows, list the values in one (or few) insert statements as this is much faster to process.
插入大量记录的时候,仅在一个(或少数几个)insert语句中列出行的值,处理起来会快很多。(一个语句,多个行,行间用逗号分隔)
6、If large numbers of rows are deleted from a table, or a table containing variable-length attributes is frequently modified, disk space may be wasted.
一个表删除大量记录,或一个包含变长字段的表频繁修改,磁盘空间将被浪费。数据没有被实际删除或修改,仅仅对其位置标注不再使用而已。浪费的磁盘空间将影响访问速度。一般需要周期性地对表进行重组优化OPTIMIZE TABLE。
7、MySQL uses statistics about a table to make decisions about how to optimize each query. You can update these statistics by running:
ANALYZE TABLE customer;
MySQL使用一个表的统计数据来决定如何优化每个查询。更新表统计数据的命令:ANALYZE TABLE ...
8、Use the Heap table type discussed in "Table Types" for small tables that are searched only for exact matches using = or <=>.
使用HEAP类型的表。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/59630/viewspace-806141/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    149
  • 访问量
    4900716