存储引擎,SQL优化

-- 存储引擎和sql优化

-- MySQL 5.5 默认的存储引擎是 MyISAM 5.6 开始是 InnoDB

-- InnoDB  事务  行级锁   外键
-- MyISAM   x    表级锁     x

-- MyISAM 适合对事务不做要求的业务系统,可以容忍少部分数据的丢失(其优势是访问快,以select,insert为主的应用基本上可以使用)

-- mysql 数据库的默认隔离级别是可重复读


-- memory 存储引擎的表结构存储在磁盘 数据存储在内存中 速度非常快 默认使用hash索引 但服务一但关闭,表中数据就会丢失


-- merge 存储引擎

-- 查看当前连接的信息 各种操作执行的次数  模糊匹配7个下划线
show status like '%Com_______';


-- 查看mysql服务启动到现在 的信息 各种操作执行的次数  模糊匹配7个下划线
show global status like '%Com_______';

-- 查看innodb的
show global status like 'Innodb_rows_%';

-- explain
-- id 值越大 优先级越高  表示该表越被先执行 值相同 从上到下依次执行


-- 查看mysql是否支持 profile
SELECT @@have_profiling;

-- 查看是否开启profiling
SELECT @@profiling;

-- 开启 profiling
set profiling = 1;


show profiles;

show profile for quer 5;

-- in 会走索引  not in 不会走索引 在写sql时尽量不要使用not in


-- sql 优化

-- 大批量插入数据


show variables like 'max_length_for_sort_data';

show variables like 'sort_buffer_size';

 

posted @ 2023-07-06 22:52  record-100  阅读(14)  评论(0)    收藏  举报