File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,9 @@ with index_data as (
1717 from pg_index
1818), redundant as (
1919 select
20- i2 .indrelid ::regclass::text as table_name,
21- i2 .indexrelid ::regclass::text as index_name,
20+ tnsp .nspname AS schema_name,
21+ trel .relname AS table_name,
22+ irel .relname AS index_name,
2223 am1 .amname as access_method,
2324 format(' redundant to index: %I' , i1 .indexrelid ::regclass)::text as reason,
2425 pg_get_indexdef(i1 .indexrelid ) main_index_def,
@@ -37,6 +38,9 @@ with index_data as (
3738 inner join pg_am am1 on op1 .opcmethod = am1 .oid
3839 inner join pg_am am2 on op2 .opcmethod = am2 .oid
3940 join pg_stat_user_indexes as s on s .indexrelid = i2 .indexrelid
41+ join pg_class as trel on trel .oid = i2 .indrelid
42+ join pg_namespace as tnsp on trel .relnamespace = tnsp .oid
43+ join pg_class as irel on irel .oid = i2 .indexrelid
4044 where
4145 not i1 .indisprimary -- index 1 is not primary
4246 and not ( -- skip if index1 is primary or uniq and index2 is primary or unique
You can’t perform that action at this time.
0 commit comments