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
mysql sql语句查询时间统计方法
最新推荐文章于 2024-08-09 11:10:24 发布