-- This is the plan that leaves the query in a hanging 'active' state Unique (cost=241.81..241.82 rows=1 width=64) -> Sort (cost=241.81..241.82 rows=1 width=64) Sort Key: ((c_1.conname)::information_schema.sql_identifier) -> Nested Loop (cost=163.39..241.80 rows=1 width=64) -> Hash Semi Join (cost=163.11..239.48 rows=1 width=104) Hash Cond: (c_1.conname = ("*SELECT* 1".constraint_name)::name) -> ProjectSet (cost=0.41..64.15 rows=1000 width=341) -> Nested Loop (cost=0.41..58.90 rows=1 width=104) Join Filter: (c_1.connamespace = nc.oid) -> Nested Loop (cost=0.41..57.81 rows=1 width=108) -> Nested Loop (cost=0.28..57.64 rows=1 width=112) -> Seq Scan on pg_constraint c_1 (cost=0.00..49.32 rows=1 width=104) Filter: (contype = ANY ('{p,u,f}'::"char"[])) -> Index Scan using pg_class_oid_index on pg_class r (cost=0.28..8.30 rows=1 width=12) Index Cond: (oid = c_1.conrelid) Filter: (relkind = ANY ('{r,p}'::"char"[])) -> Index Only Scan using pg_namespace_oid_index on pg_namespace nr (cost=0.13..0.16 rows=1 width=4) Index Cond: (oid = r.relnamespace) Filter: (NOT pg_is_other_temp_schema(oid)) -> Seq Scan on pg_namespace nc (cost=0.00..1.04 rows=4 width=4) -> Hash (cost=162.68..162.68 rows=1 width=128) -> Nested Loop (cost=35.23..162.68 rows=1 width=128) Join Filter: (pkc.conname = ("*SELECT* 1_1".constraint_name)::name) -> Subquery Scan on "*SELECT* 1_1" (cost=0.41..60.03 rows=1 width=64) -> Nested Loop (cost=0.41..60.02 rows=1 width=512) -> Nested Loop (cost=0.28..59.84 rows=1 width=68) -> Nested Loop (cost=0.00..51.49 rows=1 width=68) Join Filter: (nc_1.oid = c_2.connamespace) -> Seq Scan on pg_constraint c_2 (cost=0.00..50.40 rows=1 width=72) Filter: ((contype <> ALL ('{t,x}'::"char"[])) AND ((CASE contype WHEN 'c'::"char" THEN 'CHECK'::text WHEN 'f'::"char" THEN 'FOREIGN KEY'::text WHEN 'p'::"char" THEN 'PRIMARY KEY'::text WHEN 'u'::"char" THEN 'UNIQUE'::text ELSE NULL::text END)::text = 'PRIMARY KEY'::text)) -> Seq Scan on pg_namespace nc_1 (cost=0.00..1.04 rows=4 width=4) -> Index Scan using pg_class_oid_index on pg_class r_1 (cost=0.28..8.33 rows=1 width=8) Index Cond: (oid = c_2.conrelid) Filter: ((relkind = ANY ('{r,p}'::"char"[])) AND (pg_has_role(relowner, 'USAGE'::text) OR has_table_privilege(oid, 'INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER'::text) OR has_any_column_privilege(oid, 'INSERT, UPDATE, REFERENCES'::text))) -> Index Only Scan using pg_namespace_oid_index on pg_namespace nr_1 (cost=0.13..0.16 rows=1 width=4) Index Cond: (oid = r_1.relnamespace) Filter: (NOT pg_is_other_temp_schema(oid)) -> Merge Join (cost=34.82..102.59 rows=5 width=192) Merge Cond: (pkc.oid = d2.refobjid) Join Filter: (d1.refobjid = d2.objid) -> Nested Loop (cost=19.66..358.44 rows=5 width=200) Join Filter: (con.confrelid = pkc.conrelid) -> Index Scan using pg_constraint_oid_index on pg_constraint pkc (cost=0.27..80.95 rows=1 width=76) Filter: (contype = ANY ('{p,u}'::"char"[])) -> Merge Join (cost=19.39..277.43 rows=5 width=136) Merge Cond: (con.oid = d1.objid) -> Nested Loop (cost=2.05..1292.20 rows=5 width=136) Join Filter: (con.conname = ("*SELECT* 1".constraint_name)::name) -> Nested Loop (cost=0.55..90.37 rows=1 width=72) -> Nested Loop (cost=0.27..82.04 rows=1 width=76) Join Filter: (ncon.oid = con.connamespace) -> Index Scan using pg_constraint_oid_index on pg_constraint con (cost=0.27..80.95 rows=1 width=80) Filter: (contype = 'f'::"char") -> Seq Scan on pg_namespace ncon (cost=0.00..1.04 rows=4 width=4) -> Index Scan using pg_class_oid_index on pg_class c (cost=0.28..8.33 rows=1 width=4) Index Cond: (oid = con.conrelid) Filter: (pg_has_role(relowner, 'USAGE'::text) OR has_table_privilege(oid, 'INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER'::text) OR has_any_column_privilege(oid, 'INSERT, UPDATE, REFERENCES'::text)) -> Append (cost=1.50..1189.43 rows=992 width=64) -> Subquery Scan on "*SELECT* 1" (cost=1.50..83.09 rows=1 width=64) -> Nested Loop (cost=1.50..83.08 rows=1 width=512) -> Nested Loop (cost=1.37..82.90 rows=1 width=68) -> Hash Join (cost=1.09..50.56 rows=8 width=68) Hash Cond: (c_3.connamespace = nc_2.oid) -> Seq Scan on pg_constraint c_3 (cost=0.00..49.20 rows=96 width=72) Filter: (contype <> ALL ('{t,x}'::"char"[])) -> Hash (cost=1.04..1.04 rows=4 width=4) -> Seq Scan on pg_namespace nc_2 (cost=0.00..1.04 rows=4 width=4) -> Index Scan using pg_class_oid_index on pg_class r_2 (cost=0.28..4.04 rows=1 width=8) Index Cond: (oid = c_3.conrelid) Filter: ((relkind = ANY ('{r,p}'::"char"[])) AND (pg_has_role(relowner, 'USAGE'::text) OR has_table_privilege(oid, 'INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER'::text) OR has_any_column_privilege(oid, 'INSERT, UPDATE, REFERENCES'::text))) -> Index Only Scan using pg_namespace_oid_index on pg_namespace nr_2 (cost=0.13..0.16 rows=1 width=4) Index Cond: (oid = r_2.relnamespace) Filter: (NOT pg_is_other_temp_schema(oid)) -> Subquery Scan on "*SELECT* 2" (cost=317.60..1101.38 rows=991 width=64) -> Hash Join (cost=317.60..1091.47 rows=991 width=512) Hash Cond: (r_3.relnamespace = nr_3.oid) -> Hash Join (cost=316.51..1053.52 rows=1320 width=10) Hash Cond: (a_1.attrelid = r_3.oid) -> Seq Scan on pg_attribute a_1 (cost=0.00..716.45 rows=7823 width=6) Filter: (attnotnull AND (NOT attisdropped) AND (attnum > 0)) -> Hash (cost=306.88..306.88 rows=770 width=8) -> Seq Scan on pg_class r_3 (cost=0.00..306.88 rows=770 width=8) Filter: ((relkind = ANY ('{r,p}'::"char"[])) AND (pg_has_role(relowner, 'USAGE'::text) OR has_table_privilege(oid, 'INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER'::text) OR has_any_column_privilege(oid, 'INSERT, UPDATE, REFERENCES'::text))) -> Hash (cost=1.05..1.05 rows=3 width=4) -> Seq Scan on pg_namespace nr_3 (cost=0.00..1.05 rows=3 width=4) Filter: (NOT pg_is_other_temp_schema(oid)) -> Index Scan using pg_depend_depender_index on pg_depend d1 (cost=0.29..17.34 rows=1 width=8) Index Cond: (classid = '2606'::oid) Filter: ((refclassid = '1259'::oid) AND (refobjsubid = 0)) -> Sort (cost=15.15..15.16 rows=1 width=8) Sort Key: d2.refobjid -> Bitmap Heap Scan on pg_depend d2 (cost=4.31..15.14 rows=1 width=8) Recheck Cond: (refclassid = '2606'::oid) Filter: ((classid = '1259'::oid) AND (objsubid = 0) AND (deptype = 'i'::"char")) -> Bitmap Index Scan on pg_depend_reference_index (cost=0.00..4.31 rows=3 width=0) Index Cond: (refclassid = '2606'::oid) -> Index Scan using pg_attribute_relid_attnum_index on pg_attribute a (cost=0.29..2.31 rows=1 width=6) Index Cond: ((attrelid = r.oid) AND (attnum = ((information_schema._pg_expandarray(c_1.conkey))).x)) Filter: ((NOT attisdropped) AND (pg_has_role(r.relowner, 'USAGE'::text) OR has_column_privilege(r.oid, attnum, 'SELECT, INSERT, UPDATE, REFERENCES'::text)) AND (lower(((attname)::information_schema.sql_identifier)::text) ~~ 'xxx_%'::text))