Prepare Ci::BuildMetadata for partitioning 1/3
Ref: #373239 (closed)
What does this MR do and why?
This MR prepares Ci::BuildMetadata
for partitioning.
It creates 2 asynchronous indexes required to partition this table:
- Primary key:
ci_builds_metadata: (id, partition_id)
. - Unique constraint
ci_builds_metadata: (build_id, partition_id)
.
Indexes:
"ci_builds_metadata_pkey" PRIMARY KEY, btree (id)
"index_ci_builds_metadata_on_build_id" UNIQUE, btree (build_id)
I added another index for build_id
as I was getting the following error
PG::FeatureNotSupported: ERROR: unique constraint on partitioned table must include all partitioning columns
DETAIL: UNIQUE constraint on table "p_ci_builds_metadata" lacks column "partition_id" which is part of the partition key
In a follow up MR we will use those indexed including partition_id
to prepare this table to be partitioned as you can see in this example MR.
This will create the following schema:
Indexes:
"ci_builds_metadata_pkey" PRIMARY KEY, btree (id, partition_id)
"index_ci_builds_metadata_on_build_id_partition_id_unique" UNIQUE, btree (build_id, partition_id)
Why are we doing this?
Those indexes will be used to partition ci_builds_metadata
as explained in this MR introducing zero partition helper.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Max Orefice