Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294541

Database Queue Garbage Collection Composite Index Order

$
0
0

Problem/Motivation

We've recently run into some performance issues for a very queue heavy site. Upon investigation we identified additional load exerted on the site as a result of garbage collection for the queue table, which uses this query:

      $this->connection->delete(static::TABLE_NAME)
        ->condition('created', \Drupal::time()->getRequestTime() - 864000, '<')
        ->condition('name', 'drupal_batch:%', 'LIKE')
        ->execute();

The issue here is that a composite index exists on the queue table, with the order 'name', 'created'. This inverting of the two fields means the index cannot be fully utilised. Switching them in the query vastly improves performance for the delete.

Reference for index order

Steps to reproduce

  1. Add a number of failed batches to the queue table - haven't worked on the exact conditions that can cause this outside of our specific use case.
  2. Run garbage collection
  3. Identify slow SQL queries

Query performance

Proposed resolution

Swap order of query to match order of index.

Remaining tasks

TBC

User interface changes

N/A

Introduced terminology

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A


Viewing all articles
Browse latest Browse all 294541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>