Skip to content

Filter build association by partition_id

Max Orefice requested to merge morefice/filter-ci-build-in-by-partition-2 into master

What does this MR do and why?

Ref: #423054 (closed)

What does this MR do and why?

Following up !137399 (merged)

This MR allows to make sure we always fetch a given build record in the proper partition where the data is in by including partition_id in the where clause for the following models:

  • Ci::BuildPendingState
  • Ci::BuildTraceChunk
  • Ci::RunnerManagerBuild

This will allow us to take advantage of partition pruning and select the right partition automatically without scanning all of them.

Example of updated query

Before

SELECT "p_ci_runner_machine_builds".*
FROM "p_ci_runner_machine_builds"
WHERE "p_ci_runner_machine_builds"."build_id" = 280
AND "p_ci_runner_machine_builds"."partition_id" = 100
LIMIT 1

After

SELECT "p_ci_runner_machine_builds".*
FROM "p_ci_runner_machine_builds"
WHERE "p_ci_runner_machine_builds"."build_id" = 280
+ AND "p_ci_runner_machine_builds"."partition_id" = 100
LIMIT 1

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