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 1kPCA7-0005dH-43 for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Oct 2020 22:07:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kPCA5-0003k4-74 for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Oct 2020 22:07:21 +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 1kPCA4-0003jw-TJ for pgsql-hackers@lists.postgresql.org; Sun, 04 Oct 2020 22:07:21 +0000 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kPCA1-0005dU-R1 for pgsql-hackers@lists.postgresql.org; Sun, 04 Oct 2020 22:07:20 +0000 Received: by mail-ed1-x541.google.com with SMTP id p13so1373358edi.7 for ; Sun, 04 Oct 2020 15:07:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=4lhzCsxNAIisu+ooAk3Y4O6wrPQ2mK48ZRs1heqUF/o=; b=GNuJoH4OgNVhpuzVRxgI++HYPnP5aCG57KJLp8CaMnuu/5o2ifwGs2UfvUcostUR8F 70FIBXf4OUV3QN1YkmAWtYdWIJQm1fSeC6RRLYtk459HHq372ioTu5rqwj+o1L+5ANJj vq0m6NuEBSOhgWkS3NL4l+2DzEfcAo/4BItAwx9+MVbalDNB00TAV9OLqpzXduQFv+SJ fyodVvvnGUYQn1mKUUyols/wTQNX2L6Ua7s76qpG4Yxke+k2hLBYYZwanFUhCsHDuQwt l71XY5+4G4uk1P+suftiZre4AokxqekRPCSkQbZk1DccqmtoA8mMzkyzecNxVXz0KQwL 83tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=4lhzCsxNAIisu+ooAk3Y4O6wrPQ2mK48ZRs1heqUF/o=; b=sUn2zOIWDy3+trZc7G5dL/QQIEG/BSsBmsAh8nnzLZZLGq1ffkhQuizupErqVwsQ70 UIPCIyZVtn+fgocA0UpJua+OFYyBzszWUUbzRGCZFfd94dlisGMtoHyhnAJvabRucWhD yollI3ET06Xg+hr4P2n7aoi7b13HoQOHnnXVWxJ0nFjoLQ7gSDQLJ/SyzqOvvKwVORCQ xdvC84Z1Ym/lWid/Rng2AwvSYpimKlcVkDyclfrN4Mo1AvRnjJpp7MekLQbB66R0lWQD 4rprVH5+0VQL5yNkJ3cK/6gYZMSNmobjskCJJMTDHYnqfZbEhqBCeqRpvDYhOlhG851P 9jUA== X-Gm-Message-State: AOAM531UHsx4rxZm22ZHotH6JWZyjM06Ok6Qgpe1RWBN9UFdQsJOqEMx LuYy794AZw8RqNZ9OSV72LISBA== X-Google-Smtp-Source: ABdhPJzslkviTUPa6yYaOH3oiLQ0OGBbh4so31UI3oP+y5wrQXUNmCpW7ZqtLLMhUvdi0LJdmmwbWQ== X-Received: by 2002:a05:6402:2055:: with SMTP id bc21mr1622489edb.67.1601849236081; Sun, 04 Oct 2020 15:07:16 -0700 (PDT) Received: from localhost (ip-86-49-245-76.net.upcbroadband.cz. [86.49.245.76]) by smtp.gmail.com with ESMTPSA id q14sm6137461ejo.53.2020.10.04.15.07.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Oct 2020 15:07:15 -0700 (PDT) Date: Mon, 5 Oct 2020 00:07:13 +0200 From: Tomas Vondra To: Dilip Kumar Cc: Robert Haas , Alexander Korotkov , David Steele , Ildus Kurbangaliev , Dmitry Dolgov <9erthalion6@gmail.com>, PostgreSQL Developers Subject: Re: [HACKERS] Custom compression methods Message-ID: <20201004220713.6vlmm2e3amlz2dil@development> References: <20190228164415.62bd4107@ildus-work.localdomain> <53ab954a-bf44-2bff-fbe0-29f093899604@pgmasters.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, I took a look at this patch after a long time, and done a bit of a review+testing. I haven't re-read the whole thread since 2017 so some of the following comments might be mistaken - sorry about that :-( 1) The "cmapi.h" naming seems unnecessarily short. I'd suggest using simply compression or something like that. I see little reason to shorten "compression" to "cm", or to prefix files with "cm_". For example compression/cm_zlib.c might just be compression/zlib.c. 2) I see index_form_tuple does this: Datum cvalue = toast_compress_datum(untoasted_values[i], DefaultCompressionMethod); which seems wrong - why shouldn't the indexes use the same compression method as the underlying table? 3) dumpTableSchema in pg_dump.c does this: switch (tbinfo->attcompression[j]) { case 'p': cmname = "pglz"; case 'z': cmname = "zlib"; } which is broken as it's missing break, so 'p' will produce 'zlib'. 4) The name ExecCompareCompressionMethod is somewhat misleading, as the functions is not merely comparing compression methods - it also recompresses the data. 5) CheckCompressionMethodsPreserved should document what the return value is (true when new list contains all old values, thus not requiring a rewrite). Maybe "Compare" would be a better name? 6) The new field in ColumnDef is missing a comment. 7) It's not clear to me what "partial list" in the PRESERVE docs means. + which of them should be kept on the column. Without PRESERVE or partial + list of compression methods the table will be rewritten. 8) The initial synopsis in alter_table.sgml includes the PRESERVE syntax, but then later in the page it's omitted (yet the section talks about the keyword). 9) attcompression ... The main issue I see is what the patch does with attcompression. Instead of just using it to store a the compression method, it's also used to store the preserved compression methods. And using NameData to store this seems wrong too - if we really want to store this info, the correct way is either using text[] or inventing charvector or similar. But to me this seems very much like a misuse of attcompression to track dependencies on compression methods, necessary because we don't have a separate catalog listing compression methods. If we had that, I think we could simply add dependencies between attributes and that catalog. Moreover, having the catalog would allow adding compression methods (from extensions etc) instead of just having a list of hard-coded compression methods. Which seems like a strange limitation, considering this thread is called "custom compression methods". 10) compression parameters? I wonder if we could/should allow parameters, like compression level (and maybe other stuff, depending on the compression method). PG13 allowed that for opclasses, so perhaps we should allow it here too. 11) pg_column_compression When specifying compression method not present in attcompression, we get this error message and hint: test=# alter table t alter COLUMN a set compression "pglz" preserve (zlib); ERROR: "zlib" compression access method cannot be preserved HINT: use "pg_column_compression" function for list of compression methods but there is no pg_column_compression function, so the hint is wrong. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services