Not sure if I should report this as bug, but inserting data with $page->createChild() is extremely slow compared to using Db::insert() and I wonder why.
I followed the database content guide and wanted to insert a bunch of random data for some performance tests. I used this:
$parent = site()->page('articles');
for ($i = 0; $i < 10; $i++) {
$parent->createChild([
'slug' => Str::random(8),
'template' => 'article',
'content' => [
'title' => Str::random(8),
'text' => Str::random(16),
'status' => 'listed'
]
]);
}
…and it took about 10 seconds. Then, I switched it with:
for ($i = 0; $i < 10; $i++) {
Db::insert('articles', [
'title' => Str::random(8),
'text' => Str::random(16),
'slug' => Str::random(8),
'status' => 'listed'
]);
}
…and it happened almost instantly. Why does that happen? These pages are virtual, so it doesn’t make much sense to have such a big performance impact.
