Add index for partitioned PK on ci_job_artifacts
Technical Proposal
Prepare Ci::JobArtifact
for partitioning, similar to what we did to partition Ci::BuildMetadata.
It creates 2 asynchronous indexes required to partition this table:
- Primary key:
ci_job_artifacts: (id, partition_id)
. - Unique constraint
ci_job_artifacts: (job_id, file_type, partition_id)
.
Indexes:
"ci_job_artifacts_pkey" PRIMARY KEY, btree (id)
"index_ci_job_artifacts_on_job_id_and_file_type" UNIQUE, btree (job_id, file_type)
Use swap_primary_key to make sure the primary key include the partition key.
This will create the following schema:
Indexes:
"index_ci_job_artifacts_on_id_partition_id_unique" UNIQUE, btree (id, partition_id)
"index_ci_job_artifacts_on_job_id_and_file_type_partition_id_unique" UNIQUE, btree (job_id, file_type, partition_id)
Additionally create a synchronous index which will act as a no-op
on gitlab.com
.
You can follow the documentation to create those indexes locally.
Why are we doing this?
Those indexes will be used to partition ci_job_artifacts
as explained in this MR introducing zero partition helper.
Edited by Marius Bobin