summaryrefslogtreecommitdiff
path: root/check_postgres.pl
diff options
context:
space:
mode:
Diffstat (limited to 'check_postgres.pl')
-rwxr-xr-xcheck_postgres.pl44
1 files changed, 44 insertions, 0 deletions
diff --git a/check_postgres.pl b/check_postgres.pl
index 8bb4aced2..3b2c11558 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -5531,6 +5531,33 @@ JOIN pg_namespace n ON (n.oid = pronamespace)
}
}
+ ## Compare indexes
+
+ ## Indexes on 1 but not 2
+ INDEX1:
+ for my $name (sort keys %{$thing{1}{indexes}}) {
+ next if exists $thing{2}{indexes}{$name};
+ for my $exclude (@{$opt{exclude}}) {
+ next INDEX1 if $name =~ /$exclude/;
+ }
+
+ push @{$fail{indexes}{notexist}{1}} => $name;
+ $failcount++;
+ }
+ ## Indexes on 2 but not 1
+ INDEX2:
+ for my $name (sort keys %{$thing{2}{indexes}}) {
+ for my $exclude (@{$opt{exclude}}) {
+ next INDEX2 if $name =~ /$exclude/;
+ }
+
+ if (! exists $thing{1}{indexes}{$name}) {
+ push @{$fail{indexes}{notexist}{2}} => $name;
+ $failcount++;
+ next;
+ }
+ }
+
## Compare columns
## Any columns on 1 but not 2, or 2 but not 1?
@@ -6054,6 +6081,23 @@ JOIN pg_namespace n ON (n.oid = pronamespace)
}
}
+ ## Index differences
+
+ if (exists $fail{indexes}){
+ if (exists $fail{indexes}{notexist}) {
+ if (exists $fail{indexes}{notexist}{1}) {
+ for my $name (@{$fail{indexes}{notexist}{1}}) {
+ $db->{perf} .= " Index on 1 but not 2: $name ";
+ }
+ }
+ if (exists $fail{indexes}{notexist}{2}) {
+ for my $name (@{$fail{indexes}{notexist}{2}}) {
+ $db->{perf} .= " Index on 2 but not 1: $name ";
+ }
+ }
+ }
+ }
+
## Column differences
if (exists $fail{columns}) {
if (exists $fail{columns}{notexist}) {