Skip to content

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.

sg-gs and others added 21 commits February 4, 2026 20:22
IMPORTANT: Delete all test records from file_versions table before running this migration:
DELETE FROM file_versions WHERE 1=1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ready-for-preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants