php pdo测试批量insert into 和单条insert into对比

             // 单条插入
   for ($i = 0; $i < 1000; $i++) {
            $name             = rand(1000, 9999);
            $email            = rand(1000, 9999);
            $message          = rand(1000, 9999);
            $insertdata       = array('name' => $name, 'email' => $email, 'message' => $message);
           $this->commoninsertinfo($insertdata,'aa');
        }
          

时间2秒。。。太慢了

 

然后看看批量插入

      $insertdatalist = array();
        for ($i = 0; $i < 5000; $i++) {
            $name             = rand(1000, 9999);
            $email            = rand(1000, 9999);
            $message          = rand(1000, 9999);
            $insertdata       = array('name' => $name, 'email' => $email, 'message' => $message);
            $insertdatalist[] = $insertdata;
        }
              $this->insertss($insertdatalist, 'aa');

0.01秒。。快100倍 或者更多

上一篇:i春秋Hello World


下一篇:修改win10 默认网卡 --其实就是改网卡接口跃点