某系统反馈慢SQL影响生产,查看SLOW LOG发现下面慢SQL: SELECT COUNT(DISTINCT m.batch_no) FROM ob_relation r INNER JOIN ob_batch_d d ON r.sub_order_no = d.outbound_no INNER JOIN ob_batch_m m ON d.batch_no = m.batch_no WHERE r.production_mode =1 AND r.yn=0 AND r.outbound_n…
常规索引: 在常用查询的字段上使用常规索引 创建表时一块创建索引 create table if not exists carshop(id int not null auto_increment, uid int not null, gid int not null, primay key(id), index cuid(uid), key cgid(gid)); create table if not exists carshop(id int not null auto_increment…