@@ -1174,6 +1174,45 @@ print json.dumps(row, indent=4, ensure_ascii=False, default=__default)
11741174}
11751175```
11761176
1177+ ## 分库分表
1178+
1179+ 单表数据过大时,影响查询效率,可以根据业务逻辑进行合理的分表,库的操作同理
1180+
1181+ 通常按照主键取模,为了便于扩展,这里对偶数取模
1182+
1183+ ```
1184+ ➜ ~ mysql.server start
1185+ Starting MySQL
1186+ . SUCCESS!
1187+ ➜ ~ mysql
1188+ Welcome to the MariaDB monitor. Commands end with ; or \g.
1189+ Your MariaDB connection id is 3
1190+ Server version: 10.1.17-MariaDB Homebrew
1191+
1192+ Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
1193+
1194+ Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
1195+
1196+ MariaDB [(none)]> select 1%4, 2%4, 3%4, 4%4, 5%4, 6%4, 7%4, 8%4;
1197+ +------+------+------+------+------+------+------+------+
1198+ | 1%4 | 2%4 | 3%4 | 4%4 | 5%4 | 6%4 | 7%4 | 8%4 |
1199+ +------+------+------+------+------+------+------+------+
1200+ | 1 | 2 | 3 | 0 | 1 | 2 | 3 | 0 |
1201+ +------+------+------+------+------+------+------+------+
1202+ 1 row in set (0.00 sec)
1203+
1204+ MariaDB [(none)]> select 1%8, 2%8, 3%8, 4%8, 5%8, 6%8, 7%8, 8%8;
1205+ +------+------+------+------+------+------+------+------+
1206+ | 1%8 | 2%8 | 3%8 | 4%8 | 5%8 | 6%8 | 7%8 | 8%8 |
1207+ +------+------+------+------+------+------+------+------+
1208+ | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 0 |
1209+ +------+------+------+------+------+------+------+------+
1210+ 1 row in set (0.00 sec)
1211+
1212+ MariaDB [(none)]>
1213+ ```
1214+
1215+
11771216## 文档托管
11781217
11791218Read the Docs
0 commit comments