Fix: add composite index on DatasetUUID and ArtifactID in tags model … #6672
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Tracking issue
Closes #4583
Why are the changes needed?
The Flyte tags table lacked a composite index on the DatasetUUID and ArtifactID columns.
As a result, queries filtering by both fields (for example, fetching tags associated with a specific dataset and artifact) were less efficient, leading to unnecessary full-table scans in some cases.
This change adds a composite index to improve query performance and reduce latency in database lookups involving both columns.
What changes were proposed in this pull request?
This PR adds a composite GORM index on the DatasetUUID and ArtifactID fields in the tags model.
How this fixes the issue:
tags_dataset_uuid_artifact_id_idx
.DatasetUUID
(1) andArtifactID
(2) to ensure optimal ordering for typical query patterns.How was this patch tested?
Labels
This is important to improve the readability of release notes.
Setup process
No special setup required. Run database migrations after updating Flyte to apply the new index.
Screenshots
N/A — schema-level optimization.
Check all the applicable boxes
Related PRs
N/A
Docs link
N/A — this change affects backend model definitions only and does not modify public APIs or user-facing documentation.
Summary by Bito
This pull request introduces a composite index on the DatasetUUID and ArtifactID fields in the tags model, significantly enhancing query performance and addressing inefficiencies in database lookups. The changes optimize query execution for common patterns, improving overall application performance.