• innodb 插入性能简单测试


    create table

    
    create table test(
       id INT NOT NULL AUTO_INCREMENT,
       title VARCHAR(32) NOT NULL,
       age int ,
       PRIMARY KEY ( id )
    );
    
    

    insert script

    
    
    drop procedure if exists doWhile;
    DELIMITER //  
    CREATE PROCEDURE doWhile()   
    BEGIN
    DECLARE i INT DEFAULT 0; 
    WHILE (i <= 100000) DO
        INSERT INTO `test` (title, age) values ("testasyousee", i);
        SET i = i+1;
    END WHILE;
    END//
    DELIMITER ;
        
    CALL doWhile(); 
    
    
    
    

    ssd 用了 4 min 58 秒
    hdd 用了 45 min

    insert small

    drop procedure if exists doWhile2;
    DELIMITER //
    CREATE PROCEDURE doWhile2()
    BEGIN
    DECLARE i INT DEFAULT 0;
    WHILE (i <= 1000) DO
        INSERT INTO `test` (title, age) values ("testasyousee", i);
        SET i = i+1;
    END WHILE;
    END//
    DELIMITER ;
    
    CALL doWhile2();
    
    

    ssd : 3 秒
    hdd: 25 秒

    结论

    类型 100000 行 1000 行
    ssd 4 min 58 秒 3 秒
    hdd 45 min 25 秒
    • 本测试结果只有参考意义, 因为表结构中没有 text、blob 这些会导致 行-溢出数据 的结构, 也没有并发测试读写性能

    包含 varchar 的 insert 数据测试

    create table test(
       id INT NOT NULL AUTO_INCREMENT,
       title VARCHAR(800) NOT NULL,
       age int ,
       PRIMARY KEY ( id )
    );
    
    drop procedure if exists doWhile2;
    DELIMITER //
    CREATE PROCEDURE doWhile2()
    BEGIN
    DECLARE i INT DEFAULT 0;
    WHILE (i <= 1000) DO
        INSERT INTO `test` (title, age) values ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", i);
        SET i = i+1;
    END WHILE;
    END//
    DELIMITER ;
    
    CALL doWhile2();
    
    

    ssd: 3 秒
    hdd: 29 秒

    drop procedure if exists doWhile;
    DELIMITER //
    CREATE PROCEDURE doWhile()
    BEGIN
    DECLARE i INT DEFAULT 0;
    WHILE (i <= 100000) DO
        INSERT INTO `test` (title, age) values ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", i);
        SET i = i+1;
    END WHILE;
    END//
    DELIMITER ;
    
    CALL doWhile();
    

    ssd: 4 min 32 秒 (比 varchar(32) 的还要快,脑壳疼,不理解)

    包含 blob 字段的测试

    create table test(
       id INT NOT NULL AUTO_INCREMENT,
       title VARCHAR(800) NOT NULL,
       data blob NOT NULL,
       age int ,
       PRIMARY KEY ( id )
    );
    
    
    drop procedure if exists doWhile2;
    DELIMITER //
    CREATE PROCEDURE doWhile2()
    BEGIN
    DECLARE i INT DEFAULT 0;
    DECLARE blob_data BLOB DEFAULT hex("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", i, blob_data);
        SET i = i+1;
    END WHILE;
    END//
    DELIMITER ;
    
    CALL doWhile2();
    

    ssd: 3 秒

    drop procedure if exists doWhile;
    DELIMITER //
    CREATE PROCEDURE doWhile()
    BEGIN
    DECLARE i INT DEFAULT 0;
    DECLARE blob_data BLOB DEFAULT hex("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", i, blob_data);
        SET i = i+1;
    END WHILE;
    END//
    DELIMITER ;
    
    CALL doWhile();
    

    ssd: 4 min 52 秒
    hdd: 49 min
    看来 blob 字段没有没有降低插入速度~

  • 相关阅读:
    第一章
    第一章 计算机系统漫游
    hihocoder #1014 : Trie树
    第一章
    来个小目标
    poj 1056 IMMEDIATE DECODABILITY
    poj 2001 Shortest Prefixes
    __name__ 指示模块应如何被加载
    Python 常用函数time.strftime()简介
    CentOS安装beEF做XSS平台
  • 原文地址:https://www.cnblogs.com/tmortred/p/12993218.html
Copyright © 2020-2023  润新知