Add indexes to columns used in queries

Created on 22 April 2022, about 2 years ago
Updated 1 February 2023, over 1 year ago

Problem/Motivation

There are queries that are not using indexes where there probably should be an index. This is not a massive issue in the 99% use-case there are not lots of tokens.

Looking at \Drupal\access_unpublished\AccessTokenManager::buildAccessTokenQuery() we should have an index on expire.
Looking at \Drupal\access_unpublished\AccessTokenManager::getAccessTokensByEntity() and access_unpublished_entity_access() we should have an index on entity_type, entity_id, value.

Proposed resolution

See \Drupal\node\NodeStorageSchema for how to add index.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States recrit

    The attached patch adds the following indexes:

          $schema[$base_table]['indexes'] += [
            // Token value index for direct queries for the unique value in the url.
            'access_token__value' => ['value'],
            // Expiration index for queries to deterine active or expires.
            // @see \Drupal\access_unpublished\AccessTokenManager::buildAccessTokenQuery()
            'access_token__expire' => ['expire'],
            // Entity:Value index for queries looking values for the entity.
            // @see \Drupal\access_unpublished\AccessTokenManager::getAccessTokensByEntity()
            'access_token__entity_value' => ['entity_type', 'entity_id', 'value'],
          ];
    
Production build 0.69.0 2024