Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jGcyR-0000S0-Kq for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Mar 2020 06:23:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jGcyQ-0002nh-80 for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Mar 2020 06:23:38 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jGcyP-0002na-S6 for pgsql-hackers@lists.postgresql.org; Tue, 24 Mar 2020 06:23:38 +0000 Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jGcyI-0000p1-6C for pgsql-hackers@lists.postgresql.org; Tue, 24 Mar 2020 06:23:36 +0000 Received: by mail-qk1-x729.google.com with SMTP id d11so18228573qko.3 for ; Mon, 23 Mar 2020 23:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=qK9BGYZKR1YCebYQ+3QiBvazFolTZRTUC+/cLqjHVN8=; b=yM21jWADkaeRDV2bx/3fjujbVIkdJkwsk4vTROfW3rvGlNafhz4FCpTvksGn7+qVDP SljykuOrEJ0Oc599Yp+LMeJlhrDNTUXTaSBgt16oG2BlncdFVqum/fYNLzT6O5wq5jtF pNzOpZfJwKlA+lTUHgthxaGvSw3wPAmLFzyxOqNL6FXOkim07p5xW6CteGH2Txeforap Ux+XqDKeUnngOHvDLdZ3CLk9+SRMWtjxq7nj5cNMYpvdWWA7Gfku0oBPG2LrQI4iUspp om0+75E8Z3ANzMdowmkvDEw3FO1Autf5PIeCGzkt1VOhoDsOai2EwGY07frFjR9mpNr6 VaXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=qK9BGYZKR1YCebYQ+3QiBvazFolTZRTUC+/cLqjHVN8=; b=rmFN+6ItDgTr4KUqLVJvEmmXPh9dtopDkN7vWE0cSK3nYE+VjQWDF8DabtH1SFV4Ze thWbE5JpPEi2ZN+7GOYxkqRCLZeCprNMlGVcJs205io7Q/T7oe3kKTxRWIaC9RGnvvyM xsMUmLk4oogOpHangj2F/nbDHUtDZTAKoanZM08zDPlpcuLf3w84HboLshNI2zyfOxmG 8iu0ZJDHAo+90jhj8tE6O1VzNYyfr99eRiBAXtnQ6IXtdN98f3EP+7cM+VXuz0zHZu1h 0ryRovhBkfph4iIYhZZPkmyGxhP91EX/NNX0RWIlWseWzu0XFijW162ntPK9TrkBMTRa YF6A== X-Gm-Message-State: ANhLgQ3ybHQkgwD7jWEwQCXsYTVoUzkAAPTYUcuyyOEg8MsXd0Q3iPww 7jD0opSB8dHTMDRn4NXicWbQpA== X-Google-Smtp-Source: ADFU+vu7+7wDG+UDXLFFVEbTvQzuO5yOivEmuDzhFTXGJdgvkSrjsDjs/IYkx3ItjdydhAwYD0O21g== X-Received: by 2002:a05:620a:1301:: with SMTP id o1mr8143629qkj.34.1585031009145; Mon, 23 Mar 2020 23:23:29 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id y15sm12860418qky.33.2020.03.23.23.23.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Mar 2020 23:23:28 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id 23726800C28; Tue, 24 Mar 2020 01:23:26 -0500 (CDT) Date: Tue, 24 Mar 2020 01:23:26 -0500 From: Justin Pryzby To: Alvaro Herrera Cc: pgsql-hackers@lists.postgresql.org, Tom Lane , Thomas Munro Subject: Re: weird hash plan cost, starting with pg10 Message-ID: <20200324062325.GD21443@telsasoft.com> References: <20200323165059.GA24950@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200323165059.GA24950@alvherre.pgsql> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Mar 23, 2020 at 01:50:59PM -0300, Alvaro Herrera wrote: > 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. Your message wasn't totally clear, but this is a live bug on 13dev. It's actually broken on 9.6, but the issue isn't exposed until commit 6f236e1eb: "psql: Add tab completion for logical replication", ..which adds a nondefault ACL. I reproduced the problem with this recipe, which doesn't depend on c.relispartion or pg_get_partkeydef, and everything else shifting underfoot.. |CREATE TABLE t (i int); REVOKE ALL ON t FROM pryzbyj; explain analyze SELECT (SELECT 1 FROM (SELECT * FROM unnest(c.relacl)AS acl WHERE NOT EXISTS ( SELECT 1 FROM unnest(c.relacl) AS init(init_acl) WHERE acl=init_acl)) as foo) AS relacl , EXISTS (SELECT 1 FROM pg_depend WHERE objid=c.oid) FROM pg_class c ORDER BY c.oid; | Index Scan using pg_class_oid_index on pg_class c (cost=0.27..4704.25 rows=333 width=9) (actual time=16.257..28.054 rows=334 loops=1) | SubPlan 1 | -> Hash Anti Join (cost=2.25..3.63 rows=1 width=4) (actual time=0.024..0.024 rows=0 loops=334) | Hash Cond: (acl.acl = init.init_acl) | -> Function Scan on unnest acl (cost=0.00..1.00 rows=100 width=12) (actual time=0.007..0.007 rows=1 loops=334) | -> Hash (cost=1.00..1.00 rows=100 width=12) (actual time=0.015..0.015 rows=2 loops=179) | Buckets: 2139062143 Batches: 2139062143 Memory Usage: 8971876904722400kB | -> Function Scan on unnest init (cost=0.00..1.00 rows=100 width=12) (actual time=0.009..0.010 rows=2 loops=179) | SubPlan 2 | -> Seq Scan on pg_depend (cost=0.00..144.21 rows=14 width=0) (never executed) | Filter: (objid = c.oid) | SubPlan 3 | -> Seq Scan on pg_depend pg_depend_1 (cost=0.00..126.17 rows=7217 width=4) (actual time=0.035..6.270 rows=7220 loops=1) When I finally gave up on thinking I knew what branch was broken, I got: |3fc6e2d7f5b652b417fa6937c34de2438d60fa9f is the first bad commit |commit 3fc6e2d7f5b652b417fa6937c34de2438d60fa9f |Author: Tom Lane |Date: Mon Mar 7 15:58:22 2016 -0500 | | Make the upper part of the planner work by generating and comparing Paths. -- Justin