Skip to content

Filter generic build by partition_id

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

What does this MR do and why?

Following up !138027 (merged)

This MR allows to make sure we always fetch a given generic 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

https://explain.depesz.com/s/TNcx#bquery

SELECT p_ci_builds.*
FROM p_ci_builds
WHERE
    p_ci_builds.type = $1 AND
    p_ci_builds.status IN ( $2, $3 ) AND
    p_ci_builds.project_id = $4 AND
    p_ci_builds.commit_id = $5 AND
    p_ci_builds.name = $6 AND
    p_ci_builds.ref = $7 AND
    p_ci_builds.user_id = $8 AND
    p_ci_builds.protected = $9 AND
    p_ci_builds.stage_id = $10 AND
    p_ci_builds.stage_idx = $11 AND
    p_ci_builds.stage = $12 AND
+   p_ci_builds.partition_id = $13
LIMIT $14;
Edited by Max Orefice

Merge request reports

Loading