Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ePr8a-0002TR-JC for pgsql-bugs@arkaria.postgresql.org; Fri, 15 Dec 2017 14:38:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ePr8Z-0008CV-RC for pgsql-bugs@arkaria.postgresql.org; Fri, 15 Dec 2017 14:38:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ePr8Z-0008CL-LQ for pgsql-bugs@lists.postgresql.org; Fri, 15 Dec 2017 14:38:55 +0000 Received: from hook.sigaev.ru ([93.180.27.50]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ePr8W-0002t8-KG for pgsql-bugs@postgresql.org; Fri, 15 Dec 2017 14:38:55 +0000 Received: from xor.sai.msu.ru (unknown [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: teodor) by hook.sigaev.ru (Postfix) with ESMTPSA id 0AEC6B191AA; Fri, 15 Dec 2017 17:38:50 +0300 (MSK) Subject: Re: 10.1: hash index size exploding on vacuum full analyze To: Amit Kapila , AP , PostgreSQL Bugs References: <20171115232922.5tomkxnw3iq6jsg7@inml.weebeastie.net> <20171119233157.y5zqrn6ccvzxfw4w@inml.weebeastie.net> From: Teodor Sigaev Message-ID: Date: Fri, 15 Dec 2017 17:38:50 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi! > I think if we update the stats in copy_heap_data after copying the > data, then we don't see such problem. Attached patch should fix the > issue. You can try this patch to see if it fixes the issue for you. I'm afraid I'm not able to reproduce the problem which patch should fix. What I did (today's master, without patch): autovacuum off pgbench -i -s 100 select relname, relpages, reltuples from pg_class where relname = 'pgbench_accounts'; relname | relpages | reltuples ------------------+----------+----------- pgbench_accounts | 163935 | 1e+07 vacuum full pgbench_accounts; # select relname, relpages, reltuples from pg_class where relname = 'pgbench_accounts'; relname | relpages | reltuples ------------------+----------+----------- pgbench_accounts | 163935 | 1e+07 I've tried to add hash index to that table and print notice about number of pages and tuples immediately after estimate_rel_size() in hashbuild(). hash index got right estimation even I deleted all rows before vacuum full. What am I doing wrong? Patch looks good except, seems, updating stats is better to move to swap_relation_files(), then it will work even for toast tables. -- Teodor Sigaev E-mail: teodor@sigaev.ru WWW: http://www.sigaev.ru/