41 lines
856 B
PHP
41 lines
856 B
PHP
<?php
|
|
|
|
namespace App\Tasks\PrimaryKey;
|
|
|
|
use App\Models\ProductUuid;
|
|
use Illuminate\Support\Str;
|
|
|
|
class ProductsUuid1Task
|
|
{
|
|
|
|
/**
|
|
* insert unit
|
|
*
|
|
* 100 ............ 0,011 s DONE
|
|
* 1_000 ............ 0,041 s DONE
|
|
* 10_000 ............ 0,348 s DONE
|
|
* 100_000 ............ 3,000 s DONE
|
|
* 1_000_000 ........... 30,000 s DONE
|
|
*/
|
|
public function handle(int $count): void
|
|
{
|
|
$block = 1000;
|
|
while ($count > 0) {
|
|
|
|
if ($count < $block) {
|
|
$block = $count;
|
|
}
|
|
|
|
$products = ProductUuid::factory($block)->make(function () {
|
|
return [
|
|
'id' => Str::uuid(),
|
|
];
|
|
});
|
|
|
|
ProductUuid::query()->insert($products->toArray());
|
|
|
|
$count -= $block;
|
|
}
|
|
}
|
|
}
|