mysql 分区 + 脏读
ALTER TABLE user_2 PARTITION BY RANGE (YEAR(createTime))
(
PARTITION p1 VALUES LESS THAN (2017),
-- PARTITION user_2017 VALUES LESS THAN (2017),
-- PARTITION user_2016 VALUES LESS THAN (2016),
-- PARTITION user_2015 VALUES LESS THAN (2015),
-- PARTITION user_2014 VALUES LESS THAN (2014),
PARTITION p11 VALUES LESS THAN MAXVALUE
);
-- 查询分区情况
select
partition_name part,
partition_expression expr,
partition_description descr,
table_rows
from information_schema.partitions where
table_schema = schema()
and table_name='user_2'
-- 分区
-- 最大分区 1024
-- 建立分区:去掉外键索引,唯一索引,full-text全文检索索引,建立 createTime主键索引
-- SELECT YEAR(createTime) FROM user_2
EXPLAIN SELECT count(*) from user_2 where createTime >= '2017'
EXPLAIN SELECT count(*) from user where createTime >= '2017'
给分区分配不同的物理磁盘
https://m.aliyun.com/yunqi/ziliao/59904
脏读,是一种隔离级别,with(nolock),读取数据不加锁,spring tx 可以传 uncommit来获取脏读数据,innodb 设置并发数 128线程
http://blog.itpub.net/15498/viewspace-2141352/