Add index to actionscheduler_actions table to support prioritized claims #1250
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1104
This adds an index on wp_actionscheduler_actions that is able to support the query used to claim actions when running the queue. The current default query runs as follows:
However, there is no query to support the ordering of these actions causing the table to lock for longer periods of time.
#921 Added priorities to scheduled actions and set the default order by clause to include the priority of actions when being claimed,
'ORDER BY priority ASC, attempts ASC, scheduled_date_gmt ASC, action_id ASC'
. Though, I believe the locking was already an issue before that because there was no support for theattempts
column.The new
claim_id_status_priority_attempts_scheduled_date_gmt
index replaces the previousclaim_id_status_scheduled_date_gmt
index. I didn't come across any usage where the latter was needed. Please help me verify.Below is the analysis of both, the first using the new index while the second is the previous:
Note, that DBDelta will not automatically delete the previous index from existing installs. This will prevent the index from being removed if any sites have already added filters to the order by clause to address the performance issue.