zoukankan      html  css  js  c++  java
  • Mysql分区

    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;

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

  • 相关阅读:
    Git 简要教程
    SDK更新失败问题解决
    常用安卓操作
    MongoDB本地安装与启用(windows 7/10)
    windows 快捷键收集
    windows 常用命令
    Lambda Expression Introduction
    对 load_breast_cancer 进行 SVM 分类
    Support Vector Machine
    使用 ID3 对 Titanic 进行决策树分类
  • 原文地址:https://www.cnblogs.com/hzq3554055/p/12000847.html
Copyright © 2011-2022 走看看