Detect duplicate indexes that overlap with primary keys

What does this MR do and why?

Add primary key indexes to the duplicate index detection logic in schema specs. Previously, only secondary indexes were checked for redundancy, but many tables have separate indexes on their primary key column that duplicate the primary key index.

Primary key indexes require exact column match detection because we cannot remove them. For other indexes, prefix matching continues to identify indexes that could potentially be consolidated.

References

https://console.postgres.ai/gitlab/gitlab_production/reports/222525/files/1009393/md

How to set up and validate locally

Remove the changes from spec/support/helpers/database/duplicate_indexes.yml and run the updated specs. You should get some failures.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #583868

Merge request reports

Loading