Add index on password_policy_history to reduce update hook execution time

Created on 8 November 2022, over 2 years ago
Updated 19 June 2024, 10 months ago

Problem/Motivation

An update hook password_policy_update_8304 was added in 📌 Create hook_update to remove duplicated entries in password_policy_history Fixed . See https://git.drupalcode.org/project/password_policy/-/commit/6d8fcd6eafea...

The update hook execution time depends on how many rows are in the table password_policy_history.

On a sample Drupal 9 site, we saw an execution time of 50 minutes for the update hook.

Steps to reproduce

  1. Add loads of rows to the table password_policy_history (tens of thousands)
  2. run update hook password_policy_update_8304

Proposed resolution

Add an index on the table password_policy_history, on the following columns pass_hash and timestamp.

On the site with the 50 minute execution, this index reduced the query run time by 99%.

Remaining tasks

Write the patch

User interface changes

N/A.

API changes

N/A.

Data model changes

N/A.

📌 Task
Status

Needs review

Version

4.0

Component

Code

Created by

🇳🇿New Zealand wiifm Wellington, NZ

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

Merge Requests

Comments & Activities

Not all content is available!

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

Production build 0.71.5 2024