Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pDAsD-00021C-AD for pgsql-general@arkaria.postgresql.org; Wed, 04 Jan 2023 21:00:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pDAsA-00075F-Rj for pgsql-general@arkaria.postgresql.org; Wed, 04 Jan 2023 21:00:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pDAsA-000755-FY for pgsql-general@lists.postgresql.org; Wed, 04 Jan 2023 21:00:30 +0000 Received: from business83-4.web-hosting.com ([162.0.235.73]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pDAs3-00074U-3D for pgsql-general@lists.postgresql.org; Wed, 04 Jan 2023 21:00:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=rblst.info; s=default; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=lLLfUeWmV2xTtkRfDXdieyJJt6E/VmPn3668p32g+C4=; b=5ikZjjvGHICtLi+pLreEi9P5sX 3cnaxoZD3jZ4gnU89LWA1E9el2EDK6FDJsxbak9Rd6uJeJYVo2tw7Iupjx+jcqlO++cUShIwtsIpI OBHBhKjzgGgoSkbk2ILoS0kzv7j1GWMswS4yW6OpEuXEpYyjKFtMiEYxWPYnIXYOTranSkRJCzPwQ N/dUalsASZmmE3faOncu1qrzEFmcUC2UgzVIyhSrxx/E+TCBVGKS1Vth3mXNfv0Hk21AEQKNsh+eq FpNoNoW3NbmGMFpxQP451p2smpxohvIRuDXmiqM5Z6L4WCjmxTDCG4r+ncT17sVD8n/kOCwUchirV ++8G/lKg==; Received: from 109-61-99-122.herminatelekom.hu ([109.61.99.122]:57048 helo=[192.168.100.2]) by business83.web-hosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.95) (envelope-from ) id 1pDAru-001axl-Pm for pgsql-general@lists.postgresql.org; Wed, 04 Jan 2023 16:00:19 -0500 Message-ID: Date: Wed, 4 Jan 2023 22:00:12 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: REINDEX vs VACUUM Content-Language: hu-HU, en-US To: pgsql-general@lists.postgresql.org References: <70615d25-201f-ad4a-1291-806999ca36fb@rblst.info> <4dee765f-2196-90b9-efa1-896859552989@gmail.com> From: =?UTF-8?B?UsOpYmVsaS1TemFiw7MgVGFtw6Fz?= In-Reply-To: <4dee765f-2196-90b9-efa1-896859552989@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - business83.web-hosting.com X-AntiAbuse: Original Domain - lists.postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - rblst.info X-Get-Message-Sender-Via: business83.web-hosting.com: authenticated_id: t@rblst.info X-Authenticated-Sender: business83.web-hosting.com: t@rblst.info X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, there is a forwarder that points to the actual sender. List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I have looked more into it and have found that VACUUM FULL (and CLUSTER) does in fact rebuild indexes, see for example: https://github.com/postgres/postgres/blob/c8e1ba736b2b9e8c98d37a5b77c4ed31baf94147/src/backend/commands/cluster.c#L1463 I have also run some tests and have come to understand that REINDEX seems to "vacuum" the index in the sense that a subsequent VACUUM on the underlying table will not find any removable entries in the index. Ron is right, the term "vacuum" may be misleading. 2023. 01. 04. 16:34 keltezéssel, Ron írta: > I don't think VACUUM FULL (copy the table, create new indices and > other metadata all in one command) actually vacuums tables.  It's a > misleading name. > > Something like REBUILD TABLE would be a better name. > > On 1/4/23 07:25, Rébeli-Szabó Tamás wrote: >> Here is my understanding: >> >> REINDEX recreates the index from scratch, using the data stored in >> the underlying table. It is the same as dropping and recreating the >> index manually, with regard to the impact on the index file. It can >> free up physical space in the file system. REINDEX will not vacuum >> the index. >> >> VACUUM does many different things. One of them is vacuuming indexes >> (for the underlying table that is being vacuumed). VACUUM will remove >> index entries that are pointing to dead rows in the underlying table. >> VACUUM will not rebuild the entire index. >> >> VACUUM recycles free index blocks (using FSM), but it does not >> (usually) free up space for the file system physically. VACUUM FULL >> does that. >> >> VACUUM FULL will vacuum the index, but it will do it by making a copy >> of the index (file) and reorganizing its content in order to free up >> space physically. In that regard, it is like REINDEX. Both VACUUM >> FULL and REINDEX will block reads from the index during the process >> (by taking an ACCESS EXCLUSIVE lock). >> >> Regards, >> >> tamas >> >> 2022. 12. 31. 22:04 keltezéssel, Hao Zhang írta: >>> What is the difference between reindex and vacuum's impact on index >>> file? I deleted an indexed row. Running either vacuum or reindex >>> shows the index entry for the row is removed from the index page. I >>> was under the impression that only reindex will remove dangling >>> index entries. I am guessing that vacuum will not shrink the index >>> file and will only add deleted index entries in the free space file >>> for the index? But REINDEX is recreating the index file from scratch >>> so it is like vacuum full for index? >>> >>> Thanks >> >> >