zoukankan      html  css  js  c++  java
  • MYSQL压缩表测试

    MYSQL压缩表测试

    1. 创建表

    -- 压缩表
    SET GLOBAL innodb_file_per_table=1;
    SET GLOBAL innodb_file_format=Barracuda;
    CREATE TABLE compress_01 (
        id varchar(36) PRIMARY KEY
        ,name varchar(255)
    )
    ROW_FORMAT=COMPRESSED
    KEY_BLOCK_SIZE=8
    ;
    
    CREATE TABLE compress_02 (
        id varchar(36) PRIMARY KEY
        ,name varchar(255)
    )
    ROW_FORMAT=COMPRESSED
    KEY_BLOCK_SIZE=8
    ;
    
    CREATE TABLE compress_03 (
        id varchar(36) PRIMARY KEY
        ,name varchar(255)
    )
    ROW_FORMAT=COMPRESSED
    KEY_BLOCK_SIZE=8
    ;
    
    -- 普通表
    CREATE TABLE normal_01 (
        id varchar(36) PRIMARY KEY
        ,name varchar(255)
    )
    ;
    CREATE TABLE normal_02 (
        id varchar(36) PRIMARY KEY
        ,name varchar(255)
    )
    ;
    

    2. 造测试数据

    insert into compress_01 
    select uuid() as id, 'name_1' as name
    ;
    insert into compress_01 
    select uuid() as id, 'name_2' as name
    from compress_01
    ;
    insert into compress_01 
    select uuid() as id, 'name_3' as name
    from compress_01
    ;
    insert into compress_01 
    select uuid() as id, 'name_24' as name
    from compress_01
    ;
    

    3. 插入性能测试

    -- 3.1 压缩表 to 普通表
    insert into normal_01
    select * from compress_01
    ;
    > Affected rows: 8388608
    > 时间: 244.767s
    
    -- 3.2 普通表 to 普通表
    insert into normal_02
    select * from normal_01
    ;
    > Affected rows: 8388608
    > 时间: 242.232s
    
    -- 3.3 压缩表 to 压缩表
    insert into compress_02
    select * from compress_01
    ;
    > Affected rows: 8388608
    > 时间: 250.885s
    
    -- 3.4 普通表 to 压缩表
    insert into compress_03
    select * from normal_02
    ;
    > Affected rows: 8388608
    > 时间: 253.055s
    
    

    4. 单表查询性能测试

    -- 4.1 select查询 主键
    select * from normal_01 where id = '408f0dd5-3abb-11eb-b5bb-0242ac110002' limit 10; -- 0.037
    select * from compress_02 where id = '408f0dd5-3abb-11eb-b5bb-0242ac110002' limit 10; -- 0.039
    
    -- 4.2 select查询 索引
    
    -- 4.3 select查询 非主键
    select * from normal_01 where name = 'name_23' limit 10; -- 0.616
    select * from compress_02 where name = 'name_23' limit 10; -- 1.087
    
    -- 4.4 count查询
    select count(1) as cnt from normal_01;   -- 1.018
    select count(1) as cnt from compress_02; -- 2.269
    
    -- 4.5 count distinct 查询
    select count(distinct name) as cnt from normal_01;   -- 5.044
    select count(distinct name) as cnt from compress_02; -- 7.131
    
    -- 4.6 分页查询
    select * from normal_01 limit 50000,10; -- 0.043
    select * from compress_02 limit 50000,10; -- 0.043
    
    -- 4.6 in查询
    
    

    5. 多表关联查询性能测试(雪花模型)

    
    
    

    6. 多表关联查询性能测试(大表关联大表)

    
    
    

    7. 删除数据性能

    -- 7.1 删除记录
    -- 7.2 truncate table
    
  • 相关阅读:
    开源项目:MMTweenAnimation
    URI跳转方式地图导航的代码实践
    处理i18n国际电话区号的代码实践
    图片变形的抗锯齿处理方法
    CocoaPods版本升级
    JSPatch 部署安全策略
    JSPatch实现原理详解<二>
    JSPatch实现原理详解
    JSPatch – 动态更新iOS APP
    iOS富文本组件的实现—DTCoreText源码解析 渲染篇
  • 原文地址:https://www.cnblogs.com/chenzechao/p/14116237.html
Copyright © 2011-2022 走看看