mysql sql语句查询时间统计方法

show status;
show engines; -- 查看mysql 引擎

show variables like 'key_buffer_size'; -- 查看关键字缓冲区

show status like '%key_read%'

create table course(
cid int(3) ,
cname varchar(20),
tid int(3)
);
create table teacher(
tid int(3),
tname varchar(20) ,
tcid int(3)
);
create table teacherCard(
tcid int(3) ,
tcdesc varchar(200)
);

explain select tname from teacher where tid=1 order by tcid

alter table teacher add constraint pk_teacher PRIMARY KEY(tid)

explain select * from course where cid = 1 order by cid
explain select * from course where cid = 1 order by cname

create table test02(
a1 char(3) ,
a2 char(3) ,
a3 char(3) ,
index inx_a1(a1),
index inx_a2(a2),
index inx_a3(a3)
)
explain select * from test02 where a2 = '' and a1 = '' order by a1;
set global slow_query_log=1  -- 设置慢sql
show variables like '%slow_query_log%' -- 查看 配置信息
set  long_query_time = 5
slow_query_log_file=/h:/localhost-slow.log

show variables  like '%long_query_time%' -- 查询sql超时时间

select sleep(4) ;
select sleep(5) ;
select sleep(6) ;
select sleep(7) ;
select sleep(8) ;
select sleep(9) ;
select sleep(11) from teacher where tid = 2;


show global status like '%slow_queries%' -- 查询超时次数

set profiling = on  -- 开启 profilee
set  profiling =off
show variables like '%profiling%'

show profiles

set global general_log = 1
set global general_log=0
show variables like '%general_log%'
set global log_output='table';
select * from mysql.general_log


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值