Skip to content

perf: Delete previews in one go instead of individually #57593

@artonge

Description

@artonge

With the new preview backend, we are deleting preview individually, this is probably expensive and slow.

public function deleteAll(): void {
$lastId = 0;
while (true) {
$previews = $this->previewMapper->getPreviews($lastId, 1000);
$i = 0;
// FIXME: Should we use transaction here? Du to the I/O created when
// deleting the previews from the storage, which might be on a network
// This might take a non trivial amount of time where the DB is locked.
foreach ($previews as $preview) {
$this->deletePreview($preview);
$i++;
$lastId = $preview->getId();
}
if ($i !== 1000) {
break;
}
}
}

Shouldn't we do it in one go?

  1. Flush the preview table
  2. Delete the preview directory

Previously it was done individually too.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions