Skip to content

Filter build associations by partition_id

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

What does this MR do and why?

Ref: #423054 (closed)

What does this MR do and why?

Following up !138027 (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:

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


SELECT p_ci_builds.*
FROM p_ci_builds
INNER JOIN ci_sources_pipelines ON p_ci_builds.id = ci_sources_pipelines.source_job_id
WHERE ci_sources_pipelines.pipeline_id = 561
+ AND p_ci_builds.partition_id = 100
LIMIT 1

SELECT p_ci_builds.*
FROM p_ci_builds
INNER JOIN ci_sources_pipelines ON p_ci_builds.id = ci_sources_pipelines.source_job_id
WHERE p_ci_builds.type = 'Ci::Bridge'
  AND ci_sources_pipelines.pipeline_id = 561
+ AND p_ci_builds.partition_id = 100
LIMIT 1

Merge request reports

Loading