??????????mysql????????
???????????? ???????[ 2016/7/27 10:20:00 ] ????????????? MySQL
??????????
???????磬???????????????????????????????
?????????users??????????????????????????????????
????SELECT * FROM users WHERE name LIKE '%??%' AND sex='??' AND age=32 AND created_at BETWEEN 1388505600 AND 1420041600;
?????????users????????????????14??15????????????32???????д???‘??’??????????
??????????????????sql????????????????????????????????????????????????????????δ????????????????????????????????
????????????洢??????sql?????????????????
?????洢?? ?洢?????????
????????????InnoDB??MyIsam(???????洢????????ж??????????)
????MyIsam???
????????????????????????????????????????????????????????????????????????????????????? ???????????????? Concurrent Insert(????????)
??????????μ??????????????????????????β????????????update??delete???????????????????????λ??????????? ????????????????????????????????
??????????洢λ?????mysql?????/data/??????????£????????????????????????????????????????????д洢???????????????????????????????????й?????????????????????‘??????????’????????????????????????????????????????
??????????????????????????????2??????????????????????CMD?????myisamchk.exe -rq ?????? ???????myisamchk.exe --unpack ???? ???н????????????flush table ????????????????
??????????????
????????????
?????????????????????б???????????????????140????????????count(*)???????0.0003??
???????myisam??mysql??????洢??????????????????????????????????myisam?????????????????
????InnoDB??
????????м?????????????????????????????????????????????????MyIsam????????????ò???????????????????????????????????????????о??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????>???γ?????
???????????????????
?????????select count(*)???????????????????????primary key ????????count?????????????????140???????????е??????6s??????myisam??count???????0.00?????????????InnoDB??????????????????????????????????https://segmentfault.com/a/11...
??????????????洢λ???.frm????????洢????????????????????????????????????????????????壬?????????洢λ???windows??????c:/programData/mysql ?????????????????洢?????????е???????????‘?????’????
??????ε?洢????????????????
????????????????? ???????д洢????????????????????????????С??????????????Щ???????enum???д洢??ip??????????????洢?????Ρ????????????????????????ν??в???????????д洢
?????С????????????á??С????????????????cpu??????????????????С???????????????
???????????????null????????????????????????? NOT NULL ??????趨????
???????? ????????????
??????????????????????????????????????????????д?????????????????????????????????????????μ????????????????????????????????????????????????????
???????????????????????????????name??age??created_at?????????????????????????????????е???????name??Σ??????age??Σ????created_at??Σ???????sex???
?????????????????????????? https://segmentfault.com/a/11...
???????????з??????
????????
?????????????????????????????????????????д洢????????????飬??????飬?????????????????????????????
?????????
?????????????????????????????hash????????·????????
?????????????????????????????????????????????ж???????????λ??
??????????
????<code>$id = $_GET['id'];
????$mod = $id%5;
????$sql = "SELECT * from goods_$mod WHERE id=$id";</code>
?????????????
????//???????????????????????????ж??????е??id??????????????????洢???????
????<code>$sql = "INSERT INTO `?????` values null";
????$new_id = "SELECT mysql_insert_id()";
????$mod = $new_id%5;
????$sql = "INSERT INTO goods_$mod VALUES ($new_id?? ????1?? ????2)";</code>
???????????????????????????????????????з?????
??????????????????Ч?????????????????????????unique key
??????????????????????????洢????????????????????????????????????????????ó???洢??
????key????(????)
????<code> CREATE TABLE test_key(
????id int not null auto_increment??
????title varchar(32) not null default ''??
????price decimal(10??2) not null default 0??
????created_at datetime not null??
????PRIMARY KEY (id??created_at)
????) engine=myisam charset=utf8
????partition by key(id) partitions 5;</code>
????1
????hash????(????)
????<code> CREATE TABLE test_hash(
????id int not null auto_increment??
????title varchar(32) not null default ''??
????price decimal(10??2) not null default 0??
????created_at datetime not null ??
????PRIMARY KEY (id??created_at)
????) engine=myisam charset=utf8
????partition by hash(month(created_at)) partitions 5;</code>
????list????(??Χ)
????<code> CREATE TABLE test_list(
????id int not null auto_increment??
????title varchar(32) not null default ''??
????price decimal(10??2) not null default 0??
????created_at datetime NOT NULL??
????PRIMARY KEY (id??created_at)
????) engine=myisam charset=utf8
????partition by list(month(created_at))(
????partition spring values in (3??4??5)??
????partition summer values in (6??7??8)??
????partition autumn values in (9??10??11)??
????partition winter values in (12??1??2)
????);</code>
????range????(??Χ)
?????
????<code> CREATE TABLE test_list(
????id int not null auto_increment??
????title varchar(32) not null default ''??
????price decimal(10??2) not null default 0??
????created_at datetime NOT NULL??
????PRIMARY KEY (id??created_at)
????) engine=myisam charset=utf8
????partition by range(year(created_at))(
????partition oldest values less than 1980??
????partition old values less than 1990??
????partition middle values less than 2010??
????partition new values less than 2010
????);</code>
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11