The list of all the queries

The number of routines by the number of input parameters

Query goal: Find the number of user-defined non-trigger routines by the number of input parameters.
Notes about the query: The query excludes routines that are a part of an extension. The query also considers routines that have zero input parameters.
Query type: Sofware measure (Numeric values (software measures) about the database)
Query license: MIT License
Data source: INFORMATION_SCHEMA+system catalog
SQL query: Click on query to copy it

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 where the query belongs to

Collection nameCollection description
Find problems by overviewQueries 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 databaseQueries that return numeric values showing mostly the number of different types of database objects in the database

Categories where the query belongs to

Category nameCategory description
User-defined routinesQueries of this category provide information about the user-defined routines

The list of all the queries