Skip to content

[5.x]: Queue with lots of large jobs degrades performance #19097

Description

@charliegrinsted

What happened?

Description

When the queue contains a large number of jobs and the job column is large, the queue performance slows.

I believe this is due to the reserve method in the queue service sorting by priority, but the queue table not having an index for the priority column.

To test this, I created a dummy job class with an empty execute method and a large (200kb+) string parameter.

Obviously this is an extreme example, but we initially noticed this with Commerce jobs for order emails & catalog pricing.

When I add a composite index for channel, priority and id, performance is restored.

Steps to reproduce

  1. Push a large number of jobs into the queue, where the job column blob is also relatively large
  2. Observe query to reserve the job taking a longer amount of time

Expected behavior

Queue runs fast

Actual behavior

Queue runs slower than it could do

Craft CMS version

5.10.5

PHP version

8.5

Operating system and version

No response

Database type and version

MySQL 8.4.7

Image driver and version

No response

Installed plugins and versions

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions