SELECT tables.table_schema, tables.table_name, tables.table_rows
FROM information_schema.tables
LEFT JOIN (
SELECT table_schema, table_name
FROM information_schema.statistics
GROUP BY table_schema, table_name, index_name
HAVING
SUM(
CASE WHEN non_unique = 0 AND nullable != ‘YES’ THEN 1 ELSE 0 END
) = COUNT(*)
) puks
ON tables.table_schema = puks.table_schema AND tables.table_name = puks.table_name
WHERE puks.table_name IS NULL
AND tables.table_type = ‘BASE[……]
Read more
InnoDB的IO优化
突然要临处理线上数据库问题,等待的过程太久, 马马虎虎写了点对于IO的优化。
状态不佳,凌晨1点,要睡觉了。作为一个IT人,要切记充分锻炼、充分休息。
对于传统数据库的IO优化,一般有几个方向,如1, 减少数据库的写入。2,使用时间换空间,比如压缩。3,利用物理设备的空间时间 局部性(Locality)特征。4,把随机读写转换成顺序读写。5,缓存数据,一般传统数据库都有自己的buffer pool 。
以下简单说说具体的实现,Innodb的常用的参数、大家已知的定义、设置、作用我就不细说了。大家可以google下具体的参数作用。
减少page size 一些第三方版本早就实现了自定义的page大小,MySQL官方版本高版本才有提供此功能,低版本的话,你可以用源码编译的方式实现,如果不是追求极致的话,不建议源码编译的方式改变page size,因为可能没有经历过大规模的考验。InnoDB的压缩技术可以考虑用下,对效率和空间上取得平衡,一般16KB使用2倍压缩,8KB使用2倍压缩是可行的。
关闭 do[……]
Read more
innodb monitor 之 :解析table monitor[……]
Read more
innodb monitor 之 :解析tablespace monitor[……]
Read more
innodb monitor 之 :了解show innodb status[……]
Read more