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;

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

  • 相关阅读:
    Nginx 教程(安装在Windows)
    APS.Net Core 启用跨域请求
    C# 监听数据库表的变化(SqlDependency)
    C# WebSocket 及时通信协议
    Sqlserve 常用语句
    C# Socke t网络编程
    什么是分布式缓存
    好诗!!!
    ASP.NET MVC中获取URL地址参数的两种写法
    jQueryEasyUI Messager基本使用
  • 原文地址:https://www.cnblogs.com/hzq3554055/p/12000847.html
Copyright © 2011-2022 走看看