zoukankan      html  css  js  c++  java
  • mysql分表

    1、水平分表
    创建结构相同的N个表
    create table student_0 (
        id int not null auto_increment,
        name varchar(12),
        primary key (id)
    );
    
    create table student_1 (
        id int not null auto_increment,
        name varchar(12),
        primary key (id)
    );
    
    create table student_2 (
        id int not null auto_increment,
        name varchar(12),
        primary key (id)
    );
    
    create table student_id (
        id int not null auto_increment,
        primary key (id)
    );
    
    //伪代码
    $tableList = array(
        'student_0', 'student_1', 'student_2'
    );
    
    $tableNums = count($tableList);
    $sqlId = "insert into student_id values(null)";
    $stuId = last_insert_id();
    $tableName = $tableList[$stuId % $tableNums];
    $sql = "insert into {$tableName} values({$stuId}, '测试')";
    
    2、merge,mrg_myisam存储引擎
    mysql提供一个可以将多个结构相同的myisam表,合并到一起的存储引擎。
    
    3、垂直分表
    表中存在多个字段,将常用字段和非常用字段分别存到两张或以上的表中,
    主要目的,减少每条记录的长度。
    比如学生表:
    基础信息表student_base
    额外信息表student_extra
    基础表与额外表之间通过ID来对应。
    
    (*水平分表现在用mysql自带的partition已经很好解决了)
    
  • 相关阅读:
    Asp.Net Mvc Filter
    使用 EntityFramework后把一个对象序列化成json字符串引起循环引用的问题
    RCTF2020 calc & EasyBlog & swoole
    GKCTF-EzWeb+redis未授权访问
    BJD3rd
    http走私
    网鼎杯2020青龙组 web writeup
    De1CTF 2020 部分web
    js相关trick总结
    xss常见编码解析
  • 原文地址:https://www.cnblogs.com/jkko123/p/6294656.html
Copyright © 2011-2022 走看看