The list of all the queries

Unused foreign servers

Query goal: Find foreign servers that do not have any associated foreign tables.
Query type: Problem detection (Each row in the result could represent a flaw in the design)
Query reliability: High (Few or no false-positive results)
Query license: MIT License
Fixing suggestion: Drop the foreign server or start to use it.
Data source: INFORMATION_SCHEMA only
SQL query: Click on query to copy it

SELECT foreign_data_wrapper_name, foreign_server_name, foreign_server_type
FROM INFORMATION_SCHEMA.foreign_servers AS fs
WHERE NOT EXISTS (SELECT 1
FROM INFORMATION_SCHEMA.foreign_tables AS ft
WHERE fs.foreign_server_name=ft.foreign_server_name)
ORDER BY foreign_data_wrapper_name, foreign_server_name;

SQL statements for generating SQL statements that help us to fix the problem

SQL queryDescription
SELECT format('DROP SERVER %1$I;', foreign_server_name) AS statements
FROM INFORMATION_SCHEMA.foreign_servers AS fs
WHERE NOT EXISTS (SELECT 1
FROM INFORMATION_SCHEMA.foreign_tables AS ft
WHERE fs.foreign_server_name=ft.foreign_server_name)
ORDER BY foreign_data_wrapper_name, foreign_server_name;
Drop the foreign server.

Collections where the query belongs to

Collection nameCollection description
Find problems automaticallyQueries, that results point to problems in the database. Each query in the collection produces an initial assessment. However, a human reviewer has the final say as to whether there is a problem or not .

Categories where the query belongs to

Category nameCategory description
Distributed databaseQueries of this category provide information about the foreign table mechanism.
Unused implementation elementsQueries of this catergory provide information about the database objects that are not used.

The list of all the queries