测试了下sqlite的性能

cwb
        $start = microtime(true);
        $num = 1000;
        $step = 10000;
        $count = $step * $num;
        for ($i = 0; $i < $num; $i++) {
            $items = [];
            for ($j = 0; $j < $step; $j++) {
                $items[] = [
                    'name' => uniqid(),
                    'created' => Carbon::now()->format('Y-m-d H:i:s'),
                ];
            }
            Db::table('users')->insert($items);
        }
        $end = microtime(true);
        $output->writeln("insert " . $count/10000 . "w, use " . round($end - $start, 2) . 's');

如上代码,用webman开命令行 10个进程一起跑
写1亿条数据,用了大概12分钟

查询的时候比较奇怪,用DB Browser for SQLite查询,count总条数耗时大概3秒,用webman反而只耗时1s

阅读 216
2个回答

cwb

cwb
  • 暂无评论