chezmoi/bin/executable_scan-for-bad-indexes.sh

25 lines
460 B
Bash
Raw Normal View History

#!/bin/bash
set -e
psql -AtF',' -c 'SELECT datname FROM pg_database WHERE datistemplate = false;' | rg -v rdsadmin |
while read -r line
do
echo "running for $line"
psql -d "$line" -AtF',' -c '
SELECT pg_class.relname
FROM pg_class, pg_index
WHERE pg_index.indisvalid = false
AND pg_index.indexrelid = pg_class.oid;'
echo
done
#psql <<EOF
#EOF
#SELECT pg_class.relname
#FROM pg_class, pg_index
#AND pg_index.indexrelid = pg_class.oid;