zoukankan      html  css  js  c++  java
  • mysql性能测试php版本

    所有数据库结构都为如下,有些id是int,看注释

    100W数据:

    id为索引字段,4字节的int,数据库引擎为myisam

    echo "<br>".xdebug_time_index()."<br>";  //0.011001110076904
    
    for ($i=0; $i < 10000; $i++) { 
        $random = mt_rand(1,999999);
        $id = $random;
        $sql = "select * from test100m where id=".$id."";
        $result = mysql_query($sql,$con);
    
    }
    
    echo "<br>".xdebug_time_index()."<br>";  //1.0551059246063

    10000次查询,1s左右,每条select 0.1ms

    100W数据:

    id为索引字段,4字节的int,数据库引擎为innodb

    echo "<br>".xdebug_time_index()."<br>";  //0.011001110076904
    
    for ($i=0; $i < 10000; $i++) { 
        $random = mt_rand(1,999999);
        $id = $random;
        $sql = "select * from test100m_innodb where id=".$id."";
        $result = mysql_query($sql,$con);
    
    }
    
    echo "<br>".xdebug_time_index()."<br>";  //1.1981191635132

    10000次查询,1s左右,每条select 0.1ms

    200W数据:

    id为索引字段,4字节的int,数据库引擎为innodb

    echo "<br>".xdebug_time_index()."<br>";  //0.00099992752075195
    
    for ($i=0; $i < 1000; $i++) { 
        $random = mt_rand(1,1999999);
        $id = $random;
        $sql = "select * from test200m where id=".$id."";
        $result = mysql_query($sql,$con);
        
    }
    
    echo "<br>".xdebug_time_index()."<br>";  //4.5234520435333

    1000次查询,4.5s左右,每条select 4.5ms

    500W数据:

    id为索引字段,4字节的int,数据库引擎为innodb

    echo "<br>".xdebug_time_index()."<br>";  //0.0010001659393311
    
    for ($i=0; $i < 1000; $i++) { 
        $random = mt_rand(1,4999999);
        $id = $random;
        $sql = "select * from test500m where id=".$id."";
        $result = mysql_query($sql,$con);
        
    }
    
    echo "<br>".xdebug_time_index()."<br>";  //5.0744871616364

    1000次查询,5s左右,每条select 5ms

    1000W数据:

    id为索引字段,4字节的int,数据库引擎为myisam

    echo "<br>".xdebug_time_index()."<br>";  //0.0010008811950684
    
    for ($i=0; $i < 100; $i++) { 
        $random = mt_rand(1,9999999);
        $id = $random;
        $sql = "select * from test1000m where id=".$id."";
        $result = mysql_query($sql,$con);
        
    }
    
    echo "<br>".xdebug_time_index()."<br>";  //1.5391540527344

    100次查询,1.5s左右,每条select 15ms

    1000W数据:

    id为索引字段,8字节的bigint,数据库引擎为myisam

    echo "<br>".xdebug_time_index()."<br>";  //0.00099992752075195
    
    for ($i=0; $i < 100; $i++) { 
        $random = mt_rand(1,9999999);
        $id = $random.'0'.$random.'0';
        $sql = "select * from test1000m_bigint where id=".$id."";
        $result = mysql_query($sql,$con);
    
    }
    
    echo "<br>".xdebug_time_index()."<br>";  //1.2141208648682

    100次,时间为1.2s ,  平均每条select 12ms

    1000W数据:

    id为索引字段,8字节的bigint,数据库引擎为myisam

    代码如上

    100次,时间为1.2s  ,  平均每条select 12ms

    结论:

    数据量    引擎    平均时间  索引字段

    100W    myisam  0.1ms

    100W    innodb   0.1ms

    200W    innodb   4.5ms

    500W      innodb   5ms

    1000W      myisam     15ms  (麻痹的居然比bigint慢)

    1000W    innodb   12ms  (bigint)

    1000W    myisam  12ms  (bigint)

  • 相关阅读:
    envoy部分二: envoy的配置组件
    envoy部分一:enovy基础
    envoy部分四:envoy的静态配置
    envoy部分七:envoy的http流量管理基础
    envoy部分六:envoy的集群管理
    十七、Kubernetes的网络管理模型
    SQL 日期时间函数
    JSON 和 JavaScript eval
    Ajax 读取.ashx 返回404
    Repeat 数据为空时的处理
  • 原文地址:https://www.cnblogs.com/alazalazalaz/p/4127091.html
Copyright © 2011-2022 走看看