You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
join pg_stat_user_indexes as s ons.indexrelid=i2.indexrelid
41
+
join pg_class as trel ontrel.oid=i2.indrelid
42
+
join pg_namespace as tnsp ontrel.relnamespace=tnsp.oid
43
+
join pg_class as irel onirel.oid=i2.indexrelid
27
44
where
28
-
(regexp_replace(i1.indpred, 'location \d+', 'location', 'g') IS NOT DISTINCT FROM regexp_replace(i2.indpred, 'location \d+', 'location', 'g'))
29
-
and (regexp_replace(i1.indexprs, 'location \d+', 'location', 'g') IS NOT DISTINCT FROM regexp_replace(i2.indexprs, 'location \d+', 'location', 'g'))
30
-
and ((i1.nkeys>i2.nkeysand not i2.indisunique) OR (i1.nkeys=i2.nkeysand ((i1.indisuniqueandi2.indisuniqueand (i1.indexrelid>i2.indexrelid)) or (not i1.indisuniqueand not i2.indisuniqueand (i1.indexrelid>i2.indexrelid)) or (i1.indisuniqueand not i2.indisunique))))
31
-
andi1.key_array[1:i2.nkeys]=i2.key_array
45
+
not i1.indisprimary-- index 1 is not primary
46
+
and not ( -- skip if index1 is (primary or uniq) and is NOT (primary and uniq)
47
+
(i1.indisprimaryori1.indisunique)
48
+
and (not i2.indisprimaryor not i2.indisunique)
49
+
)
50
+
andam1.amname=am2.amname-- same access type
51
+
and (
52
+
i2.columnslike (i1.columns||'%') -- index 2 includes all columns from index 1
53
+
ori1.columns=i2.columns-- index1 and index 2 includes same columns
54
+
)
55
+
and (
56
+
i2.opclasseslike (i1.opclasses||'%')
57
+
ori1.opclasses=i2.opclasses
58
+
)
59
+
-- index expressions is same
60
+
and pg_get_expr(i1.indexprs, i1.indrelid) is not distinct from pg_get_expr(i2.indexprs, i2.indrelid)
61
+
-- index predicates is same
62
+
and pg_get_expr(i1.indpred, i1.indrelid) is not distinct from pg_get_expr(i2.indpred, i2.indrelid)
join pg_stat_user_indexes as s ons.indexrelid=i2.indexrelid
67
80
where
68
-
(regexp_replace(i1.indpred, 'location \d+', 'location', 'g') IS NOT DISTINCT FROM regexp_replace(i2.indpred, 'location \d+', 'location', 'g'))
69
-
and (regexp_replace(i1.indexprs, 'location \d+', 'location', 'g') IS NOT DISTINCT FROM regexp_replace(i2.indexprs, 'location \d+', 'location', 'g'))
70
-
and ((i1.nkeys>i2.nkeysand not i2.indisunique) OR (i1.nkeys=i2.nkeysand ((i1.indisuniqueandi2.indisuniqueand (i1.indexrelid>i2.indexrelid)) or (not i1.indisuniqueand not i2.indisuniqueand (i1.indexrelid>i2.indexrelid)) or (i1.indisuniqueand not i2.indisunique))))
71
-
andi1.key_array[1:i2.nkeys]=i2.key_array
81
+
not i1.indisprimary-- index 1 is not primary
82
+
and not ( -- skip if index1 is (primary or uniq) and is NOT (primary and uniq)
83
+
(i1.indisprimaryori1.indisunique)
84
+
and (not i2.indisprimaryor not i2.indisunique)
85
+
)
86
+
andam1.amname=am2.amname-- same access type
87
+
and (
88
+
i2.columnslike (i1.columns||'%') -- index 2 includes all columns from index 1
89
+
ori1.columns=i2.columns-- index1 and index 2 includes same columns
90
+
)
91
+
and (
92
+
i2.opclasseslike (i1.opclasses||'%')
93
+
ori1.opclasses=i2.opclasses
94
+
)
95
+
-- index expressions are same
96
+
and pg_get_expr(i1.indexprs, i1.indrelid) is not distinct from pg_get_expr(i2.indexprs, i2.indrelid)
97
+
-- index predicates are same
98
+
and pg_get_expr(i1.indpred, i1.indrelid) is not distinct from pg_get_expr(i2.indpred, i2.indrelid)
0 commit comments