Query goal: | Find the number of user-defined non-trigger routines based on their schema, security type, and being deterministic. The routines can be used to implement virtual data layer. Thus the queriy gives some indications about the possible extent of the layer. |
Notes about the query: | The query only returns data about schemas that have at least one routine. The query excludes routines that are a part of an extension. ROLLUP ensures that the number of routines based on some combinations of the properties and the total number of routines is found. |
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 routine_name, routine_schema, security_type, is_deterministic FROM information_schema.routines WHERE routine_schema NOT IN (SELECT schema_name FROM INFORMATION_SCHEMA.schemata WHERE schema_name<>'public' AND schema_owner='postgres' AND schema_name IS NOT NULL) AND (data_type<>'trigger' OR data_type IS NULL) AND routine_name NOT IN ('f_assume_you_must_use_files', 'f_check_format_comma_separated_list', 'f_check_password', 'f_default_value_with_no_match') AND NOT EXISTS (SELECT 1 FROM pg_catalog.pg_depend d inner join pg_catalog.pg_proc pc ON d.objid=pc.oid WHERE EXISTS (SELECT 1 FROM pg_catalog.pg_extension e WHERE d.refobjid=e.oid) AND pc.proname || '_' || pc.oid = routines.specific_name)) SELECT routine_schema, security_type, is_deterministic, Count(*) AS nr_of_routines FROM routines GROUP BY ROLLUP (routine_schema, security_type, is_deterministic) ORDER BY routine_schema, security_type, is_deterministic, Count(*) DESC; |
Collection name | Collection 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 |
Category name | Category description |
---|---|
User-defined routines | Queries of this category provide information about the user-defined routines |