Goal Find the number of views, the number of views with and without security barrier setting, and the names of views with and without the security barrier setting.
Type Sofware measure (Numeric values (software measures) about the database)
License MIT License
Data Source INFORMATION_SCHEMA+system catalog
SQL Query
SELECT 
Count(*) AS nr_of_views,
Count(*) FILTER (WHERE (pg_catalog.pg_class.reloptions::text~*'security_barrier=(true|on|1)')) AS nr_of_security_barrier_views,
Count(*) FILTER (WHERE ((pg_catalog.pg_class.reloptions::text!~*'security_barrier=(true|on|1)' 
OR pg_catalog.pg_class.reloptions IS NULL) AND pg_get_viewdef(pg_class.oid)~*'WHERE[[:space:]]')) AS nr_of_non_security_barrier_views_with_where,
Count(*) FILTER (WHERE (pg_catalog.pg_class.reloptions::text!~*'security_barrier=(true|on|1)' 
OR pg_catalog.pg_class.reloptions IS NULL)) AS nr_of_non_security_barrier_views,
string_agg(nspname || '.' || relname ,',
' ORDER BY nspname , relname ) FILTER (WHERE (pg_catalog.pg_class.reloptions::text~*'security_barrier=(true|on|1)')) AS security_barrier_views, string_agg(nspname || '.' || relname ,',
' ORDER BY nspname , relname ) FILTER (WHERE (pg_catalog.pg_class.reloptions::text!~*'security_barrier=(true|on|1)' OR pg_catalog.pg_class.reloptions IS NULL)) AS non_security_barrier_views FROM pg_catalog.pg_class, pg_catalog.pg_namespace WHERE pg_catalog.pg_class.relnamespace=pg_catalog.pg_namespace.oid AND relkind='v' AND nspname NOT IN (SELECT schema_name FROM information_schema.schemata WHERE schema_name<>'public' AND schema_owner='postgres' AND schema_name IS NOT NULL);
Collections

This query belongs to the following collections:

NameDescription
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

This query is classified under the following categories:

NameDescription
Derived tablesQueries of this category provide information about the derived tables (views, materialized views), which are used to implement virtual data layer.