Skip to content

Prepare Ci::Build for partitioning

Max Orefice requested to merge morefice/prepare-ci-builds-partitioning into master

Ref: #382033 (closed)

What does this MR do and why?

This MR prepares Ci::Build for partitioning, similar to what we did to partition Ci::BuildMetadata.

Those indexes will be created during low traffic peak this weekend as ci_builds is one the busiest table 🤞

It creates 2 asynchronous indexes required to partition this table:

  • Primary key: ci_builds: (id, partition_id).
  • Unique constraint ci_builds: (token_encrypted, partition_id).
Indexes:
    "ci_builds_pkey" PRIMARY KEY, btree (id)
    "index_ci_builds_on_token_encrypted" UNIQUE, btree (token_encrypted) WHERE token_encrypted IS NOT NULL

In a follow up MR we will use swap_primary_key to make sure the primary key include the partition key.

This will create the following schema:

Indexes:
    "index_ci_builds_on_id_partition_id_unique" UNIQUE, btree (id, partition_id)
    "index_ci_builds_on_token_encrypted_partition_id_unique" UNIQUE, btree (token_encrypted, partition_id) WHERE token_encrypted IS NOT NULL

You can follow the documentation to create those indexes locally.

Why are we doing this?

Those indexes will be used to partition ci_builds 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.

Edited by Max Orefice

Merge request reports