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.89) (envelope-from ) id 1hEa3u-0005lj-EO for pgsql-general@arkaria.postgresql.org; Thu, 11 Apr 2019 13:48:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hEa3t-0001ba-7T for pgsql-general@arkaria.postgresql.org; Thu, 11 Apr 2019 13:48:17 +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 1hEa3s-0001WH-RM for pgsql-general@lists.postgresql.org; Thu, 11 Apr 2019 13:48:16 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hEa3q-0002OY-J1 for pgsql-general@postgresql.org; Thu, 11 Apr 2019 13:48:15 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x3BDm6Ea008561; Thu, 11 Apr 2019 09:48:07 -0400 From: Tom Lane To: rihad cc: pgsql-general General Subject: Re: When do vacuumed pages/tuples become available for reuse? In-reply-to: <9cd73fcb-511d-ede9-6789-209b7d4eb193@mail.ru> References: <9cd73fcb-511d-ede9-6789-209b7d4eb193@mail.ru> Comments: In-reply-to rihad message dated "Thu, 11 Apr 2019 11:19:43 +0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <8559.1554990486.1@sss.pgh.pa.us> Date: Thu, 11 Apr 2019 09:48:06 -0400 Message-ID: <8560.1554990486@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk rihad writes: > If an autovacuum job on a huge table runs for 5-6 hours, do its freed > pages/tuples become available for reuse immediately when they are marked > as free, or only at the end of the multi-hour vacuum operation? They'll be freed in batches, where the size of a batch depends on the autovacuum_work_mem or maintenance_work_mem setting. The basic work cycle is * scan table to find dead tuples, save their TIDs in working memory; continue until end of table or working memory full * scan indexes to find index entries matching those TIDs, remove 'em * go back to table and remove the previously-found tuples * if not end of table, repeat So a larger work-mem setting means fewer passes over the indexes, but a longer time until space is reclaimed. regards, tom lane