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 1qnZfJ-00BJhu-Aj for pgsql-general@arkaria.postgresql.org; Tue, 03 Oct 2023 07:17:57 +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 1qnZfH-0021Ty-SL for pgsql-general@arkaria.postgresql.org; Tue, 03 Oct 2023 07:17:56 +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 1qnZfH-0021Te-Ap for pgsql-general@lists.postgresql.org; Tue, 03 Oct 2023 07:17:55 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qnZfE-007vht-4J for pgsql-general@lists.postgresql.org; Tue, 03 Oct 2023 07:17:54 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40652e570d9so6077925e9.1 for ; Tue, 03 Oct 2023 00:17:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20230601.gappssmtp.com; s=20230601; t=1696317470; x=1696922270; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=TIh62IE1xWxlJ83/Oy2a/WAST8OXbF90jallqKPCaBs=; b=3ILPZkQiebIuWeUrOiGBZUi379HNt2p3X7bn050h46FXv9a5OZP2+DklAkMHK+DFNA fX1XzmnA6CwssCz6GmTPl9YiJeBMJ+MxG8KGbBIpgMlPQZM6QYev/UHq0UoMVx/o1xK4 2Ldk0MVxFbYFmBF+seVUrK5r1kodgAw8rpJEPAm6Ohsn9tVXxWt8rsKjNy5/DY38EgJ1 UK58Ntx6gMN4WlMFXCk9n+UDOkC8PQJo1kabdS4DyxfYq4howgg8dxNbK3RS2XLTHI1S QUt8TSlyT+25OgQ6wZ/on81Ka15gV9FuS7tA8kmuJmQe4RXUEJFod7EpNxkoJy79qsLO yZBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696317470; x=1696922270; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=TIh62IE1xWxlJ83/Oy2a/WAST8OXbF90jallqKPCaBs=; b=M8lLo++SYiniBs04S8KDU7kDknUdHHBv2b7C0qtLDNp7b8nugfUY3mbe1FP530s+PB BDBwSz8VflmRbR7Vh9M2ytzo39+VkeiDodYnjavvyZJPJLg7Eo7i5DRgn2frSuTA7Ka5 XEcEdm22wQmrPVWfaEg6C0tHZY+Ac1bnCibQs+DI2n2mt+sK1ViFKfVCNKhhyUQqTkwh pecCmmRdYonF0svj0oeX7fdkNEneohnWIdYaOvUhDgYhlLMRDxZno22oc+AXMho50iT2 NzniJDNY4lMPcABaPQWRRwPJyMRS5Z3IRaPnvOOF1dWKHfEEPs+DJ2f5Ojk5v6NzWrk7 vP6w== X-Gm-Message-State: AOJu0Yz2riPo5Avgn2aIydsYnkRkXnXudVo+o72ISUypIUjAOAiHzebq zO/cPgnOpo2gBUnp3PVx02fqZw== X-Google-Smtp-Source: AGHT+IFxqufQRMPRY5SFPoXvf1Khd4AA8xQ5f7YpmLu+xhjQqQdspNFIaKlJs5j8C8OK2M7UBvSIsw== X-Received: by 2002:a05:600c:acd:b0:405:37bb:d940 with SMTP id c13-20020a05600c0acd00b0040537bbd940mr12259692wmr.0.1696317470359; Tue, 03 Oct 2023 00:17:50 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:1c0:45b9:97:dde5:9bad]) by smtp.gmail.com with ESMTPSA id z3-20020a5d4d03000000b003232f167df5sm838500wrt.108.2023.10.03.00.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 00:17:50 -0700 (PDT) Message-ID: <2eb92d315e13af55c96c12f7b0ea1e9b6d5826a3.camel@cybertec.at> Subject: Re: How to force "re-TOAST" after changing STORAGE or COMPRESSION? From: Laurenz Albe To: Dominique Devienne , Michael Paquier Cc: rob stone , pgsql-general@lists.postgresql.org Date: Tue, 03 Oct 2023 09:17:49 +0200 In-Reply-To: References: <069c100e455299d6e1aa80bda283a397fadf1926.camel@tpg.com.au> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2023-10-03 at 09:08 +0200, Dominique Devienne wrote: > =C2=A0In my case, it's OK not to be transactional, for these experiments.= Is there a way > to lock the table and do the rewriting w/o generating any WAL? I don't ha= ve any experience > with unlogged tables, but should I take an exclusive lock on the table, s= witch it to unlogged, > rewrite, and switch it back to logged? The only way to avoid WAL is to use unlogged tables, but they lose their da= ta after a crash. If you change an unlogged table to a logged table, the whol table= ends up in WAL, so you won't save anything that way. The best thing that you can do to reduce the amount of WAL is to TRUNCATE a= nd populate the table in the same transaction. Then, if you have "wal_level = =3D minimal", PostgreSQL can forego writing WAL information. But you cannot have archive= recovery and replication with "wal_level =3D minimal". > What about my last question about whether storage=3Dextended always being= compressed? > Given that I don't see much compression, at least when looking indirectly= via total-rel-sizes? > Is there a way to evaluate the compression ratios achieved on TOASTED val= ues? If you don't see much compression in your toasted data, it is possible that= you are storing data that are already compressed. In that case, PostgreSQL will at= tempt compression with its algorithms that are geared at speed rather than good c= ompression. If it finds that the data grew after compression, it will discard the compr= essed value and continue with the original value. To avoid that useless compression at= tempt, you should use STORAGE EXTERNAL in such cases. Yours, Laurenz Albe