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

提升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类型的表。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值