Hello

While messing with EXPLAIN on a query emitted by pg_dump, I noticed that
current Postgres 10 emits weird bucket/batch/memory values for certain
hash nodes:

                         ->  Hash  (cost=0.11..0.11 rows=10 width=12) (actual 
time=0.002..0.002 rows=1 loops=8)
                               Buckets: 2139062143  Batches: 2139062143  Memory 
Usage: 8971876904722400kB
                               ->  Function Scan on unnest init_1  
(cost=0.01..0.11 rows=10 width=12) (actual time=0.001..0.001 rows=1 loops=8)

It shows normal values in 9.6.

The complete query is:

SELECT c.tableoid, c.oid, c.relname, (SELECT pg_catalog.array_agg(acl ORDER BY 
row_n) FROM (SELECT acl, row_n FROM 
pg_catalog.unnest(coalesce(c.relacl,pg_catalog.acldefault(CASE WHEN c.relkind = 
'S' THEN 's' ELSE 'r' END::"char",c.relowner))) WITH ORDINALITY AS 
perm(acl,row_n) WHERE NOT EXISTS ( SELECT 1 FROM 
pg_catalog.unnest(coalesce(pip.initprivs,pg_catalog.acldefault(CASE WHEN 
c.relkind = 'S' THEN 's' ELSE 'r' END::"char",c.relowner))) AS init(init_acl) 
WHERE acl = init_acl)) as foo) AS relacl, (SELECT pg_catalog.array_agg(acl 
ORDER BY row_n) FROM (SELECT acl, row_n FROM 
pg_catalog.unnest(coalesce(pip.initprivs,pg_catalog.acldefault(CASE WHEN 
c.relkind = 'S' THEN 's' ELSE 'r' END::"char",c.relowner))) WITH ORDINALITY AS 
initp(acl,row_n) WHERE NOT EXISTS ( SELECT 1 FROM 
pg_catalog.unnest(coalesce(c.relacl,pg_catalog.acldefault(CASE WHEN c.relkind = 
'S' THEN 's' ELSE 'r' END::"char",c.relowner))) AS permp(orig_acl) WHERE acl = 
orig_acl)) as foo) as rrelacl, NULL AS initrelacl, NULL as initrrelacl, 
c.relkind, c.relnamespace, (SELECT rolname FROM pg_catalog.pg_roles WHERE oid = 
c.relowner) AS rolname, c.relchecks, c.relhastriggers, c.relhasindex, 
c.relhasrules, 'f'::bool AS relhasoids, c.relrowsecurity, 
c.relforcerowsecurity, c.relfrozenxid, c.relminmxid, tc.oid AS toid, 
tc.relfrozenxid AS tfrozenxid, tc.relminmxid AS tminmxid, c.relpersistence, 
c.relispopulated, c.relreplident, c.relpages, am.amname, CASE WHEN c.reloftype 
<> 0 THEN c.reloftype::pg_catalog.regtype ELSE NULL END AS reloftype, 
d.refobjid AS owning_tab, d.refobjsubid AS owning_col, (SELECT spcname FROM 
pg_tablespace t WHERE t.oid = c.reltablespace) AS reltablespace, 
array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded')
 AS reloptions, CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 
'LOCAL'::text WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 
'CASCADED'::text ELSE NULL END AS checkoption, tc.reloptions AS 
toast_reloptions, c.relkind = 'S' AND EXISTS (SELECT 1 FROM pg_depend WHERE 
classid = 'pg_class'::regclass AND objid = c.oid AND objsubid = 0 AND 
refclassid = 'pg_class'::regclass AND deptype = 'i') AS is_identity_sequence, 
EXISTS (SELECT 1 FROM pg_attribute at LEFT JOIN pg_init_privs pip ON (c.oid = 
pip.objoid AND pip.classoid = 'pg_class'::regclass AND pip.objsubid = 
at.attnum)WHERE at.attrelid = c.oid AND ((SELECT pg_catalog.array_agg(acl ORDER 
BY row_n) FROM (SELECT acl, row_n FROM 
pg_catalog.unnest(coalesce(at.attacl,pg_catalog.acldefault('c',c.relowner))) 
WITH ORDINALITY AS perm(acl,row_n) WHERE NOT EXISTS ( SELECT 1 FROM 
pg_catalog.unnest(coalesce(pip.initprivs,pg_catalog.acldefault('c',c.relowner)))
 AS init(init_acl) WHERE acl = init_acl)) as foo) IS NOT NULL OR (SELECT 
pg_catalog.array_agg(acl ORDER BY row_n) FROM (SELECT acl, row_n FROM 
pg_catalog.unnest(coalesce(pip.initprivs,pg_catalog.acldefault('c',c.relowner)))
 WITH ORDINALITY AS initp(acl,row_n) WHERE NOT EXISTS ( SELECT 1 FROM 
pg_catalog.unnest(coalesce(at.attacl,pg_catalog.acldefault('c',c.relowner))) AS 
permp(orig_acl) WHERE acl = orig_acl)) as foo) IS NOT NULL OR NULL IS NOT NULL 
OR NULL IS NOT NULL))AS changed_acl, pg_get_partkeydef(c.oid) AS partkeydef, 
c.relispartition AS ispartition, pg_get_expr(c.relpartbound, c.oid) AS 
partbound FROM pg_class c LEFT JOIN pg_depend d ON (c.relkind = 'S' AND 
d.classid = c.tableoid AND d.objid = c.oid AND d.objsubid = 0 AND d.refclassid 
= c.tableoid AND d.deptype IN ('a', 'i')) LEFT JOIN pg_class tc ON 
(c.reltoastrelid = tc.oid AND c.relkind <> 'p') LEFT JOIN pg_am am ON (c.relam 
= am.oid) LEFT JOIN pg_init_privs pip ON (c.oid = pip.objoid AND pip.classoid = 
'pg_class'::regclass AND pip.objsubid = 0) WHERE c.relkind in ('r', 'S', 'v', 
'c', 'm', 'f', 'p') ORDER BY c.oid

I'm not looking into this right now.  If somebody is bored in
quarantine, they might have a good time bisecting this.

-- 
Álvaro Herrera


Reply via email to