Postgres duplicate indexes

30 views Asked by At

I'm new to Postgres world.

DB migrated from DB2 to aurora postgres : we have lot of performance issues. one of the weird thing I've noticed almost every table have duplicate indexes some of them repeated columns. and every primary key index also have unique index. here's example of on of the table portion.

enter image description here

is it normal ? is there a way to cleanup ?

Thanks!

I've tried below query to find duplicates which resulted 1900 rows.

SELECT *
FROM pg_index AS ind
JOIN pg_class c ON ind.indexrelid = c.oid
WHERE EXISTS ( SELECT 1
FROM pg_index AS ind2
WHERE ind.indrelid = ind2.indrelid
AND ( ind.indkey @> ind2.indkey
OR ind.indkey <@ ind2.indkey )
AND ind.indkey[0] = ind2.indkey[0]
AND ind.indkey <> ind2.indkey
AND ind.indexrelid <> ind2.indexrelid
AND ( ind.indkey::int[] @> ind2.indkey::int[]
OR ind.indkey::int[] <@ ind2.indkey::int[] )
) 
0

There are 0 answers