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 1lekKt-00031A-Lu for pgsql-hackers@arkaria.postgresql.org; Thu, 06 May 2021 20:11:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lekKs-0001wj-Kc for pgsql-hackers@arkaria.postgresql.org; Thu, 06 May 2021 20:11:02 +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 1lekKs-0001wQ-83 for pgsql-hackers@lists.postgresql.org; Thu, 06 May 2021 20:11:02 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lekKp-00057Q-FO for pgsql-hackers@postgresql.org; Thu, 06 May 2021 20:11:01 +0000 Received: by mail-pl1-x62a.google.com with SMTP id v20so3984412plo.10 for ; Thu, 06 May 2021 13:10:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=TEkLk4zkv039DEoPi9+LP/lQ71Hk79I3a05ixGt0zTs=; b=gU9aStDkA/d+vMrHd+tbZ5Hf1NjmB0Rc0BrFP1ihXZFhWURHoiJYZTRjdpknXJ6jhh 2ZD6r+ehVePQ4OT/argIqyFgwVZD1UsuPwQ23tsNQHDN8gMsztO2o8wBANc+3mOhs+EK +A11H3xhiFxOPORSrq1XwexgXyJfeIoDsxWtwxiFJUtYMSFLS83GjxIMyT7HTLaywW7v Go395DZ6EBo+72vz7FSSxVt0BqYs0VZXSWd/vsSZ16oH85HyBEwQ+pEJoPdyi+2OsEsP UPv7gFRqr2DXyggLcRy7yRu+PIt6gPccOuzBWscCTPWgT+LAgbXNQ4jE4hqT7s8l5E+z fXGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=TEkLk4zkv039DEoPi9+LP/lQ71Hk79I3a05ixGt0zTs=; b=RVBgJvrJIfmlahX6VZrJsvYHHhkCBEHXDGoAsZXCRxjjrynHLWQpgeOxZeTwHbQj/x fx9dBW4v4PKEPXoChvUuSmKKDFMLGwCeyzsVKfa4k4+aUBmeLJeFWH64bWoftfPZR/GX M9hmCzq4wpTpnbRSRgtru34ffxdsAOsd5VJLIpqK4ybPyA+K3Jq6n4lmnDDGLBDw3yxd 4cF2+qq9akPKYjMSY9KZpzt5WKYpej61FfxzkbecUX02x2ox/zi3jgEh+f/LZ46Kqpsq TVzc02hj1igsDaQDdbr35vugfWv+vWk+gucoIR3IpwiofWm4+ClYD+iQPOolib1drp/r zWWQ== X-Gm-Message-State: AOAM530pgomFhVLA8nNePdmfPIdjhHAqPGEHrzZoqXFvIhKzqJ1MFkiW V68SnITNYcI48nrslCId0bxiDA== X-Google-Smtp-Source: ABdhPJz9GnRRJxpNEAB/kYe17HDofE2xlOS58yyOKZS6dhQk8TR4kRMIYtQnJCx66Z4GdViChTFjUw== X-Received: by 2002:a17:90a:5885:: with SMTP id j5mr19801931pji.102.1620331855846; Thu, 06 May 2021 13:10:55 -0700 (PDT) Received: from jdavis.lan (c-73-231-146-4.hsd1.ca.comcast.net. [73.231.146.4]) by smtp.gmail.com with ESMTPSA id u20sm2687232pgl.27.2021.05.06.13.10.54 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 May 2021 13:10:55 -0700 (PDT) Message-ID: <35333ea26e52252174515e14671a9fbc1c20c8fa.camel@j-davis.com> Subject: Re: alter table set TABLE ACCESS METHOD From: Jeff Davis To: Michael Paquier , Justin Pryzby Cc: pgsql-hackers@postgresql.org, Jacob Champion , Heikki Linnakangas , Ashwin Agrawal , Ashutosh Sharma , Andres Freund , Robert Haas , Amit Kapila , Alvaro Herrera , Dilip Kumar Date: Thu, 06 May 2021 13:10:53 -0700 In-Reply-To: References: <20210228222530.GD20769@telsasoft.com> <20210308010707.GA29832@telsasoft.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2021-03-08 at 16:30 +0900, Michael Paquier wrote: > This toast issue is a kind of interesting one, and it seems rather > right to rely on toast_build_flattened_tuple() to decompress things > if > both table AMs support toast with the internals of toast knowing what > kind of compression has been applied to the stored tuple, rather than > have the table AM try to extra a toast tuple by itself. I wonder > whether we should have a table AM API to know what kind of > compression > is supported for a given table AMs at hand, because there is no need > to flatten things if both the origin and the target match their > compression algos, which would be on HEAD to make sure that both the > origin and table AMs have toast (relation_toast_am). Your patch, > here, would flatten each tuples as long as the table AMs don't > match. That can be made cheaper in some cases. I am confused by this. The toast-related table AM API functions are: relation_needs_toast_table(), relation_toast_am(), and relation_fetch_toast_slice(). What cases are we trying to solve here? 1. target of conversion is tableam1 main table, heap toast table 2. target of conversion is tableam1 main table, no toast table 3. target of conversion is tableam1 main table, tableam1 toast table 4. target of conversion is tableam1 main table, tableam2 toast table Or does the problem apply to all of these cases? And if tableam1 can't handle some case, why can't it just detoast the data itself? Shouldn't that be able to decompress anything? For example, in columnar[1], we just always detoast/decompress because we want to compress it ourselves (along with other values from the same column), and we never have a separate toast table. Is that code incorrect, or will it break in v14? Regards, Jeff Davis https://github.com/citusdata/citus/blob/6b1904d37a18e2975b46f0955076f84c8a387cc6/src/backend/columnar/columnar_tableam.c#L1433