Skip to content

Performance degradation for mass inserts in v0.16.7 #2353

@iquito

Description

@iquito

When upgrading from Phinx v0.16.6 to v0.16.7 the time needed to run my migrations when running tests went from 12 seconds to 364 seconds. Specifically the one migration suffered by far the most, it went from 2 seconds to 354 seconds and it looks similar to this (slightly simplified):

final class NumbersInitialData extends AbstractMigration
{
    private array $numbers = [
        // about 150'000 numbers
    ];

    public function up(): void
    {
        $table = $this->table('numbers');

        // about 150'000 inserts
        foreach ($this->numbers as $prefix => $length) {
            $table->insert([
                'prefix' => $prefix,
                'count' => $length,
            ]);
        }

        // Save insert only at the end
        $table->save();
    }
}

What this should do, as far as I know, is create those 150'000 inserts and then bulk-insert them with the $table->save(); at the end. Something changed significantly with Phinx v0.16.7 to slow down these kind of inserts. If I downgrade to Phinx v0.16.6 (and everything else stays the same) the speed goes back to 2 seconds. I checked the release notes for v0.16.7, but could not find any indication what could cause such a massive performance change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions