Filter Ci::Build#without_archived_trace by partition_id
Ref: #430294 (closed)
What does this MR do and why?
This MR filters Ci::Build#without_archived_trace
by partition_id
.
This query was identified not leveraging partition pruning and it is being used by Ci::ArchiveTraceWorker.
Example of updated query
SELECT p_ci_builds.*
FROM p_ci_builds
WHERE p_ci_builds.type = 'Ci::Build'
AND (NOT EXISTS
(SELECT 1
FROM p_ci_job_artifacts
WHERE p_ci_job_artifacts.job_id = p_ci_builds.id
+ AND p_ci_job_artifacts.partition_id = p_ci_builds.partition_id
AND p_ci_job_artifacts.file_type = 3))
This will allow us to take advantage of partition pruning and select the right partition automatically without scanning all of them.
Edited by Max Orefice