Commit c29adfe7 authored by drew cimino's avatar drew cimino Committed by Adam Hegyi

Schedule async index build for ci_job_artifacts

Our purpose-built index for removal of expired records from
ci_job_artifacts does not exclude artifacts where expire_at is null.
This means job traces, which get unlocked but have no expiration, are
polluting an index that would otherwise be a clean ready-for-removal
queue and much smaller.

Changelog: performance
parent 4d048f64
# frozen_string_literal: true
class PrepareIndexForCiJobArtifactsUnlockedWithExpireAt < Gitlab::Database::Migration[1.0]
TABLE_NAME = 'ci_job_artifacts'
INDEX_NAME = 'index_ci_job_artifacts_on_expire_at_for_removal'
CONDITIONS = 'locked = 0 AND expire_at IS NOT NULL'
def up
prepare_async_index TABLE_NAME, [:expire_at], where: CONDITIONS, name: INDEX_NAME
end
def down
unprepare_async_index_by_name TABLE_NAME, INDEX_NAME
end
end
fd738cf8a5642f96dc67a294dcf913d797b580a19f35d5ef76573c63bf2dd920
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment