Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rV7HL-00EwWG-Gi for pgsql-hackers@arkaria.postgresql.org; Wed, 31 Jan 2024 09:53:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rV7HK-00CwiL-Cp for pgsql-hackers@arkaria.postgresql.org; Wed, 31 Jan 2024 09:53:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rV7HK-00CwiD-0D for pgsql-hackers@lists.postgresql.org; Wed, 31 Jan 2024 09:53:10 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rV7HG-004IxS-Ti for pgsql-hackers@postgresql.org; Wed, 31 Jan 2024 09:53:08 +0000 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a349ed467d9so601102966b.1 for ; Wed, 31 Jan 2024 01:53:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20230601.gappssmtp.com; s=20230601; t=1706694785; x=1707299585; darn=postgresql.org; h=message-id:date:content-transfer-encoding:content-id:mime-version :comments:references:in-reply-to:subject:cc:to:from:from:to:cc :subject:date:message-id:reply-to; bh=fNy4kSmz/izfLKI7em5DIbG3KWSWdlLFOHIbcqIdFDE=; b=jkDyxo+TbV1GeFAdc4Q9klgcOlTDONc/yBl9au/MuxOw8cq8IRGgUt+IzZIriScppv j6tFnuwq5GrcLqig0uKCKoOT2tDNy9q8Dm5hyfYWVVcTF44XPsMPRg6LlcNq21MMd1Yr NEUJ3s9YiQsH0m/W38bLTYTfTkqGjqevyPS4B9BMzE7cIjGe08IiTKOMdkqoOysxAYHM jeuCFMhapOIX7CUSPRqk1S/H1KFoSp6GGXdr+RxqK6/9u8Y8QtJC3yN1VtfIyxQm2Nz6 V+n/oY0Fs0xEij6XAvojDRaw9viCY2xYbGv1EhBuNr8AuqDbDWMhVaYdFqjhahewwzd7 Ho2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706694785; x=1707299585; h=message-id:date:content-transfer-encoding:content-id:mime-version :comments:references:in-reply-to:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fNy4kSmz/izfLKI7em5DIbG3KWSWdlLFOHIbcqIdFDE=; b=Aju85FBCkdFaVYMU0+MFVpsPz0UGWfDWxqqqWtIcQoHX/yLm5nYSW3qClRsKYVgpeV cNSLLjbbMgngUpY/21LiHfZuIJdqtYuOS0rQbUw3B/Y8/kRQ+Rk5DOE1pNYMBD9Q3SpK 0aDSQMIl5Mjq8RF+xcAPLUjum/nDd87tnIFdmHhu5dTznxaLHAMmisTFI5N+g4NXlPSS 7uFCqRmmkQmIBGj5R2Osuymx078lubszDxEJebJxKKnkujXJer/KI2Rf/kmRCabg7T1X 40Mn2BpWWQfTvQOj5OusODxFlNXsW1EJKZvRV5e4bLSAlcvCU9/RHGvpYpwX0vpxLaiU 2YGw== X-Gm-Message-State: AOJu0YwMOlx6pnfvzhac0iDQka9MYeV1AQk+2VtociJg2NXtPq8a/bMK 5vpMNgqm2HewOcW3MSr6uPX2SM/sGWgpkQxs3BHgUyxXYbfZlxpxaiYnIaZEEthwWNwx3yP/eqB X X-Google-Smtp-Source: AGHT+IEqQdT0jhxeKU22Zsuf0s6/4iL/c/hq2iOlDwRwsgltgjxSwaVHHGzehGCZmuNI9tI4uOeNIw== X-Received: by 2002:a17:906:c454:b0:a35:34c0:e1bd with SMTP id ck20-20020a170906c45400b00a3534c0e1bdmr659637ejb.67.1706694785433; Wed, 31 Jan 2024 01:53:05 -0800 (PST) Received: from antos (109-81-174-152.rct.o2.cz. [109.81.174.152]) by smtp.gmail.com with ESMTPSA id j9-20020a170906254900b00a311685890csm6022741ejb.22.2024.01.31.01.53.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 01:53:05 -0800 (PST) From: Antonin Houska To: Alvaro Herrera cc: Pavel Stehule , Michael Paquier , PostgreSQL Hackers Subject: Re: why there is not VACUUM FULL CONCURRENTLY? In-reply-to: <202401301031.7viyzjhkmal4@alvherre.pgsql> References: <202401301031.7viyzjhkmal4@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Tue, 30 Jan 2024 11:31:17 +0100." X-Mailer: MH-E 8.6+git; nmh 1.8; GNU Emacs 28.2.50 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <5185.1706694913.1@antos> Content-Transfer-Encoding: quoted-printable Date: Wed, 31 Jan 2024 10:55:13 +0100 Message-ID: <5186.1706694913@antos> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alvaro Herrera wrote: > On 2024-Jan-30, Pavel Stehule wrote: > = > > One of my customer today is reducing one table from 140GB to 20GB. No= w he > > is able to run archiving. He should play with pg_repack, and it is wor= king > > well today, but I ask myself, what pg_repack does not be hard to do > > internally because it should be done for REINDEX CONCURRENTLY. This is= not > > a common task, and not will be, but on the other hand, it can be nice = to > > have feature, and maybe not too hard to implement today. But I didn't = try it > = > FWIW a newer, more modern and more trustworthy alternative to pg_repack > is pg_squeeze, which I discovered almost by random chance, and soon > discovered I liked it much more. > = > So thinking about your question, I think it might be possible to > integrate a tool that works like pg_squeeze, such that it runs when > VACUUM is invoked -- either under some new option, or just replace the > code under FULL, not sure. If the Cybertec people allows it, we could > just grab the pg_squeeze code and add it to the things that VACUUM can > run. There are no objections from Cybertec. Nevertheless, I don't expect much c= ode to be just copy & pasted. If I started to implement the extension today, I= 'd do some things in a different way. (Some things might actually be simpler = in the core, i.e. a few small changes in PG core are easier than the related workarounds in the extension.) The core idea is that: 1) a "historic snapshot" is used to get the current contents of the table, 2) logical decoding is used to capture the changes = done while the data is being copied to new storage, 3) the exclusive lock on th= e table is only taken for very short time, to swap the storage (relfilenode)= of the table. I think it should be coded in a way that allows use by VACUUM FULL, CLUSTE= R, and possibly some subcommands of ALTER TABLE. For example, some users of pg_squeeze requested an enhancement that allows the user to change column = data type w/o service disruption (typically when it appears that integer type i= s going to overflow and change bigint is needed). Online (re)partitioning could be another use case, although I admit that commands that change the system catalog are a bit harder to implement than VACUUM FULL / CLUSTER. One thing that pg_squeeze does not handle is visibility: it uses heap_inse= rt() to insert the tuples into the new storage, so the problems described in [1= ] can appear. The in-core implementation should rather do something like tup= le rewriting (rewriteheap.c). Is your plan to work on it soon or should I try to write a draft patch? (I assume this is for PG >=3D 18.) [1] https://www.postgresql.org/docs/current/mvcc-caveats.html -- = Antonin Houska Web: https://www.cybertec-postgresql.com