文章目录
一、单表优化
建表:
create table article(
id int unsigned not null primary key auto_increment,
author_id int unsigned not null,
category_id int unsigned not null,
views int unsigned not null,
comments int unsigned not null,
title varchar(255) not null,
content text not null
);
打印
Query OK, 0 rows affected (0.05 sec)
插入数据:
insert into article(`author_id`,`category_id`,`views`,`comments`,`title`,`content`) values
(1,1,1,1,'1','1'),
(2,2,2,2,'2','2'),
(1,1,3,3,'3','3');
打印
Query OK, 3 rows
本文详细介绍了MySQL的表优化和索引优化,包括单表、双表和三表优化,以及索引创建和使用原则。通过案例分析了全值匹配、最左前缀、索引失效等情况,并提供了排序优化的建议,强调小表驱动大表的原则,旨在提升数据库查询性能。
订阅专栏 解锁全文
2081

被折叠的 条评论
为什么被折叠?



