Chinaunix首页 | 论坛 | 博客
  • 博客访问: 549817
  • 博文数量: 36
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1749
  • 用 户 组: 普通用户
  • 注册时间: 2013-08-20 16:13
个人简介

中国科学院大学计算机硕士,曾在新浪爱彩数据库组带DBA团队,现居新加坡。wx: lihui_dba

文章分类

全部博文(36)

文章存档

2020年(2)

2019年(3)

2017年(7)

2016年(1)

2015年(7)

2014年(11)

2013年(5)

分类: Mysql/postgreSQL

2015-03-11 17:33:22

1.为查询缓存优化你的查询
  例:curdate()、now()、'2015-01-01',前两者都不能利用到数据库的查询缓存,尽量采用常量
2.不使用永久链接
3.innodb_read_io_threads的调优:看innodb状态,如果pending read较大,则调整,调整后观察pending read
4.SQL_NO_CACHE的真正作用是禁止缓存查询结果,但并不意味着cache不作为结果返回给query。
5.limit的优化:
定时器的sql示例如下:
select * from table where status=0 limit 29800,200;
select * from table where status=0 limit 30000,200;
select * from table where status=0 limit 30200,200;
limit分页到这个程度,就非常慢了。
调优办法:
select * from table where status=0 and id>0 limit 0,200;
select * from table where status=0 and id>200 limit 0,200;
select * from table where status=0 and id>400 limit 0,200;
调优后效果非常显著,sql执行起来几乎无延迟。
参考资料:《高性能MySQL》 第三版
阅读(2736) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~