fix: updated Invalid Indexes query
@@ -18,9 +18,9 @@ class Databases(Plugin):
query_age = "select age(datfrozenxid) from pg_catalog.pg_database where datistemplate = false " \
"and datname = :'p1';"
query_invalid_indexes = "SELECT count (*) " \
- "FROM pg_catalog.pg_index " \
- "WHERE pg_catalog.pg_index.indisvalid = false " \
- "AND pg_catalog.pg_index.indexrelid NOT IN (SELECT DISTINCT relation FROM pg_catalog.pg_locks WHERE relation IS NOT NULL);"
+ "FROM pg_catalog.pg_index i LEFT JOIN pg_catalog.pg_locks l " \
+ "ON (i.indexrelid = l.relation) " \
+ "WHERE i.indisvalid = false AND l.relation IS NULL;"
# queries for zabbix agent
query_agent_discovery = "SELECT json_build_object ('data',json_agg(json_build_object('{#DATABASE}',d.datname)))" \
