Skip to content

feat(migration): drop legacy unique index on folders table#883

Open
jzunigax2 wants to merge 1 commit intomasterfrom
chore/drop-legacy-plainName-parentid-index
Open

feat(migration): drop legacy unique index on folders table#883
jzunigax2 wants to merge 1 commit intomasterfrom
chore/drop-legacy-plainName-parentid-index

Conversation

@jzunigax2
Copy link
Contributor

@jzunigax2 jzunigax2 commented Jan 19, 2026

What

Drop the legacy unique index folders_plainname_parentid_key from the folders table, now that the replacement index folders_parentuuid_plainname_unique has been deployed in PR #882.

Why

1. Index is no longer used

The legacy index has not been scanned since 2026-01-07, when the optimized idx_folders_user_parentuuid_plainname_not_deleted_removed index was introduced.

Metric Value
Last scanned 2026-01-07 (12+ days ago)
Size 5,940 MB
Historical scans 2.6B
Historical tuple reads 88T
Historical tuple fetches 3,115

2. Redundant uniqueness enforcement

With PR #882 merged, we now have a proper unique constraint on (parent_uuid, plain_name) that:

  • Aligns with application code (findByNameAndParentUuid)
  • Uses optimal column order (high-cardinality column first)

The legacy index on (plain_name, parent_id) is now fully redundant.

3. Write performance impact

Despite not being scanned, the index is still maintained on every write operation.

4. Disk space recovery

Dropping this index reclaims 5,940 MB of disk space.

How

Migration uses DROP INDEX CONCURRENTLY to avoid table locks:

DROP INDEX CONCURRENTLY IF EXISTS folders_plainname_parentid_key;

@jzunigax2 jzunigax2 requested a review from sg-gs January 19, 2026 21:25
@jzunigax2 jzunigax2 self-assigned this Jan 19, 2026
@jzunigax2 jzunigax2 added the enhancement New feature or request label Jan 19, 2026
@sonarqubecloud
Copy link

@github-actions
Copy link

github-actions bot commented Feb 4, 2026

This PR is stale because it has been open for more than 15 days with no activity.

@github-actions
Copy link

This PR is stale because it has been open for more than 15 days with no activity.

@jzunigax2 jzunigax2 force-pushed the chore/drop-legacy-plainName-parentid-index branch from d6dfa6e to a60e01c Compare February 25, 2026 02:53
@jzunigax2 jzunigax2 requested a review from apsantiso as a code owner February 25, 2026 02:53
@github-actions github-actions bot removed the stalled label Feb 26, 2026
@jzunigax2 jzunigax2 force-pushed the chore/drop-legacy-plainName-parentid-index branch from a60e01c to eb48c4e Compare March 3, 2026 04:27
@apsantiso apsantiso added the migration-required A migration is included in the PR label Mar 4, 2026
@jzunigax2 jzunigax2 force-pushed the chore/drop-legacy-plainName-parentid-index branch from eb48c4e to 187f7c8 Compare March 4, 2026 15:42
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 4, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request migration-required A migration is included in the PR ready-for-preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants