Remove join from TaggableQueries.arel_tag_names_array for models supporting tag_name
Summary
Update the TaggableQueries.arel_tag_names_array method to use the tag_name column directly for models that support it, removing the need to join to the tags table.
Context
This is part of the work to handle FKs from ci_runner_taggings to tags as tracked in #467664.
Now that ci_runner_taggings.tag_name is populated, indexed, and non-nullable, we can optimize queries by reading directly from this column instead of joining to the tags table. This will:
- Improve query performance by eliminating a join
- Reduce cross-database foreign key dependencies
- Support the Cells architecture by keeping data local
Implementation
- Identify all models that use
TaggableQueries.arel_tag_names_array - Update the method to check if the model supports the
tag_namecolumn - For models with
tag_namesupport (likeCi::Runner), query directly from the taggings table - For models without
tag_namesupport, maintain the existing join behavior - Add or update tests to verify the new query path
- Monitor query performance to ensure improvements
Prerequisites
-
tag_namecolumn backfilled (#570217 (closed)) -
tag_namecolumn is non-nullable -
tag_namecolumn is indexed
Related Issues
- Parent: #467664
- Backfill: #570217 (closed)
Edited by Pedro Pombeiro