Skip to content

Conversation

@RGB-loop
Copy link

@RGB-loop RGB-loop commented Dec 5, 2025

Problem

The buffer_zones table has a foreign key constraint on (blob_id, project_id) referencing general_blobs, but there's no index on these columns.

This causes:

  • Full table scans during CASCADE DELETE when general_blobs records are deleted
  • Slow JOIN queries between BufferZone and GeneralBlob

Solution

Add index idx_buffer_zones_blob_id_project_id on (blob_id, project_id) columns.

Migration

After deploying, run the following SQL to add the index to existing databases:

CREATE INDEX idx_buffer_zones_blob_id_project_id
ON buffer_zones (blob_id, project_id);## Testing

  • Verified the index is created correctly in local development
  • Tested CASCADE DELETE performance improvement

Add index on (blob_id, project_id) to BufferZone table to optimize:
- JOIN queries between BufferZone and GeneralBlob
- CASCADE DELETE performance when GeneralBlob records are deleted

Without this index, cascade deletes would cause full table scans.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant