Create p_ci_builds_tags table
To partition and shard the taggings table we need to create tables for each polymorphic relation. For its relation with p_ci_builds we must create a new table p_ci_builds_tags to encapsulate the many to many relation between tags and jobs.
p_ci_builds_tags should have these columns:
id bigint-
tag_id bigint, FK totags -
(build_id, partition_id) bigints, FK top_ci_builds -
project_id bigint, needed for sharding
An unique index on (tag_id, build_id, partition_id) to ensure that tags are unique per job. The table must be partitioned by partition_id, more details https://docs.gitlab.com/ee/development/cicd/cicd_tables.html