Skip to content

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

Merged
sg-gs merged 1 commit into
masterfrom
chore/drop-legacy-plainName-parentid-index
Apr 1, 2026
Merged

feat(migration): drop legacy unique index on folders table#883
sg-gs merged 1 commit into
masterfrom
chore/drop-legacy-plainName-parentid-index

Conversation

@jzunigax2
Copy link
Copy Markdown
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
Copy Markdown

@github-actions
Copy link
Copy Markdown

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
Copy Markdown

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
@jzunigax2 jzunigax2 force-pushed the chore/drop-legacy-plainName-parentid-index branch from 187f7c8 to 5639acf Compare March 12, 2026 14:14
@jzunigax2 jzunigax2 force-pushed the chore/drop-legacy-plainName-parentid-index branch from 5639acf to b7a8e4e Compare March 20, 2026 04:25
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Member

@sg-gs sg-gs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running migration @jzunigax2

@sg-gs
Copy link
Copy Markdown
Member

sg-gs commented Apr 1, 2026

Migration run @jzunigax2

Sequelize CLI [Node: 22.16.0, CLI: 6.6.3, ORM: 6.37.7]

Loaded configuration file "src/config/sequelize.js".
Using environment "production".
== 20260320042454-drop-legacy-unique-index-folders-plainname-parentid: migrating =======
== 20260320042454-drop-legacy-unique-index-folders-plainname-parentid: migrated (3.357s)

Done in 5.68s.

@sg-gs sg-gs merged commit 1d7839d into master Apr 1, 2026
13 checks passed
@sg-gs sg-gs deleted the chore/drop-legacy-plainName-parentid-index branch April 1, 2026 09:45
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.

3 participants