union 合并多个表的查询结果创建索引表的拆分

mysql.jpg

union 合并多个表的查询结果

创建索引:

规律:

where 条件中出现的字段要创建索引

where 条件中出现多个字段,要创建联合索引

order by 中出现的排序字段,要创建索引

group by 中出现的字段要用上索引

一个表的外键要创建索引

表的拆分:

日志的数据量,进行userid,hash分区存储

create table blog(

id int key auto_increment,

title varchar(200),

content text,

userid int,

pubtime int

primary key(id,userid)

)partition by hash(userid) partitions 3;


最后编辑于:2021/05/24作者: 牛逼PHP

发表评论