首页 > 数据库技术 > 详细

Mysql分区

时间:2019-12-07 11:06:44      阅读:69      评论:0      收藏:0      [点我收藏+]

 

Myisam:多个小表一个聚合表,逻辑上的

Innodb:物理文件的划分

注意事项

 

Show plugins

Show engines

Show variables like ‘%partition%

 

 

分区方式:Range、LIST、HASH、KEY,5.5版本之后支持非整形的Range和List分区;Hash分区不支持字符串

 

 

Explain:sql优化常用命令,比如Explain partitions select * from tbl1 where uuid=80

Select * from tbl where uuid=8 partition(p1)

 

Select * from information_schema.partions where table_schema=’test’ and table_name=’tbl_1’ \G;

 

 

Show global variables like ‘%datadir%’;

 

Range分区

Create table tb1(uuid int not null,name varchar(20))

Partition by range(uuid)(

Partition p0 values less than(5),

Partition p1 values less than(10),

Partition p2 values less than maxvalue

)

或者list分区

Partition by list(uuid)

partitions(

Partition p0 values in (1,2,3)

)

 

Patition by hash(mod(uuid,2))

( partition 3)

 

Alter table tb1 remove partitioning

 

 

分区列需要包含唯一索引或者主键;不支持有外键的表做分区;不支持全文索引;数据和索引都会产生分区文件;单条记录查询在分区中是没有优势的,因为需要做分区选择,插入等其他操作也是需要成本的;分区字段不要使用null;

 

 

分区可以做删除、合并、重建等操作,含不删除数据 单独针对分区的操作

Mysql分区

原文:https://www.cnblogs.com/hzq3554055/p/12000847.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!