Chinaunix首页 | 论坛 | 博客
  • 博客访问: 350675
  • 博文数量: 166
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1640
  • 用 户 组: 普通用户
  • 注册时间: 2015-05-05 11:44
个人简介

文章不在长,坚持不懈记录下努力前行的脚步

文章分类

全部博文(166)

文章存档

2017年(19)

2016年(59)

2015年(88)

我的朋友

分类: Mysql/postgreSQL

2016-01-11 14:09:40

1.查询sql:SELECT IFNULL(SUM(acctsessiontime),0) sumacct FROM radacct a WHERE a.username= '15054693897' AND a.acctstoptime IS NOT NULL
2.无索引
(1)执行计划
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE a range ind_acctst ind_acctst 6 (NULL) 1434442 Using index condition; Using where
(2)sql执行时间
state duration (summed) in sec percentage
Sending data 6.42342 99.97930
(3)总耗时      : 7.038 sec
3.创建索引
(1) ALTER TABLE `qwifi`.`radacct`   
  ADD  INDEX `index_usr_stoptime` (`username`, `acctstoptime`);
(2)执行计划
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE a range ind_acctst ind_acctst 200 (NULL) 64 Using index condition
(3)总耗时      : 0.092 sec
阅读(852) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~