WITH routines AS (SELECT
pg_namespace.nspname AS specific_schema,
pg_proc.proname || '_' || pg_proc.oid AS specific_name
FROM
pg_catalog.pg_proc,
pg_catalog.pg_namespace,
pg_catalog.pg_type
WHERE
pg_proc.pronamespace = pg_namespace.oid
AND pg_proc.prorettype=pg_type.oid
AND pg_type.typname<>'trigger'
AND pg_proc.proname NOT IN ('f_assume_you_must_use_files', 'f_check_format_comma_separated_list', 'f_check_password', 'f_default_value_with_no_match')
AND pg_namespace.nspname NOT IN (SELECT schema_name
FROM INFORMATION_SCHEMA.schemata
WHERE schema_name<>'public' AND
schema_owner='postgres' AND schema_name IS NOT NULL)
AND NOT EXISTS (SELECT 1
FROM pg_catalog.pg_depend d
WHERE EXISTS (SELECT 1 FROM pg_catalog.pg_extension e WHERE d.refobjid=e.oid) AND
d.objid=pg_proc.oid)),
in_params AS (SELECT specific_schema, specific_name
FROM information_schema.parameters
WHERE parameter_mode='IN'),
parameters_stats AS (SELECT specific_schema, specific_name, Count(in_params.specific_name) AS nr_of_parameters
FROM routines LEFT JOIN in_params USING (specific_schema, specific_name)
GROUP BY specific_schema, specific_name)
SELECT nr_of_parameters, Count(*) AS nr_of_routines
FROM parameters_stats
GROUP BY nr_of_parameters
ORDER BY nr_of_routines DESC;
Collections
This query belongs to the following collections:
Name
Description
Find problems by overview
Queries that results point to different aspects of database that might have problems. A human reviewer has to decide based on the results as to whether there are problems or not .
Find quick numeric overview of the database
Queries that return numeric values showing mostly the number of different types of database objects in the database
Categories
This query is classified under the following categories:
Name
Description
User-defined routines
Queries of this category provide information about the user-defined routines