Skip to content

Turn indexes on ci_builds.token into partial index

Follow-up from #332472 (comment 594309105):

gitlabhq_production=# select indexrelname, idx_scan, idx_tup_read, idx_tup_fetch, pg_size_pretty(pg_relation_size(indexrelname::regclass)) from pg_stat_user_indexes where relname = 'ci_builds' order by pg_relation_size(indexrelname::regclass) desc;
                          indexrelname                          |  idx_scan  | idx_tup_read | idx_tup_fetch | pg_size_pretty 
----------------------------------------------------------------+------------+--------------+---------------+----------------
 index_ci_builds_on_token                                       |  101049006 |         7019 |          7019 | 114 GB
 index_ci_builds_on_token_encrypted                             |  297055834 |    196035431 |     196006818 | 95 GB
...

index_ci_builds_on_token should be made partial with WHERE token IS NOT NULL.

Edited by Andreas Brandl