Skip to content

Drop full index on ci_builds.token

Andreas Brandl requested to merge ab/remove-token-index into master

What does this MR do?

This change drops the full index on ci_builds (token) which has been replaced with a partial index on ci_builds (token) WHERE token IS NOT NULL instead (see !64221 (merged)).

This index is a flat line in terms of index scans on GitLab.com: https://thanos-query.ops.gitlab.net/graph?g0.range_input=1d&g0.max_source_resolution=0s&g0.expr=sum(rate(pg_stat_user_indexes_idx_scan%7Benv%3D%22gprd%22%2C%20relname%3D%22ci_builds%22%2C%20indexrelname%3D%22index_ci_builds_on_token%22%7D%5B5m%5D))&g0.tab=0

The partial index isn't being used either, but this reflects that non-encrypted tokens are not relevant for GitLab.com anymore.

Relates to #333812 (closed)

Migration log

== 20210629104933 DropIndexOnCiBuildsForToken: reverting ======================
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:ci_builds, :token, {:unique=>true, :name=>:index_ci_builds_on_token, :algorithm=>:concurrently})
   -> 0.0075s
-- execute("SET statement_timeout TO 0")
   -> 0.0004s
-- add_index(:ci_builds, :token, {:unique=>true, :name=>:index_ci_builds_on_token, :algorithm=>:concurrently})
   -> 0.0156s
-- execute("RESET ALL")
   -> 0.0006s
== 20210629104933 DropIndexOnCiBuildsForToken: reverted (0.0249s) =============

== 20210629104933 DropIndexOnCiBuildsForToken: migrating ======================
-- transaction_open?()
   -> 0.0000s
-- indexes(:ci_builds)
   -> 0.0080s
-- execute("SET statement_timeout TO 0")
   -> 0.0005s
-- remove_index(:ci_builds, {:algorithm=>:concurrently, :name=>:index_ci_builds_on_token})
   -> 0.0091s
-- execute("RESET ALL")
   -> 0.0006s
== 20210629104933 DropIndexOnCiBuildsForToken: migrated (0.0188s) =============

Does this MR meet the acceptance criteria?

Conformity

Edited by Andreas Brandl

Merge request reports