Skip to content
  • Yorick Peterse's avatar
    Remove various redundant indexes · b51554837051
    Yorick Peterse authored
    One can see which indexes are used in PostgreSQL by running the
    following query:
    
        SELECT relname as table_name, indexrelname as index_name, idx_scan, idx_tup_read, idx_tup_fetch, pg_size_pretty(pg_relation_size(indexrelname::regclass))
        FROM pg_stat_all_indexes
        WHERE schemaname = 'public'
        AND "idx_scan" = 0
        ORDER BY pg_relation_size(indexrelname::regclass) desc;
    
    Using this query I built a list of indexes that could be potentially
    removed. After checking every single one by hand to make sure they
    really aren't used I only found 1 index that _would_ be used. This was a
    GitLab GEO index (EE) specific that's currently not used simply because
    the table is empty.
    
    Apart from this one index all indexes could be removed. The migration
    also takes care of 6 composite indexes that can be replaced with a
    single column index, which in most cases was already present.
    
    For more information see gitlab-org/gitlab-ce#20767.
    b51554837051