Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ePBry-00016A-M0 for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Dec 2017 18:35:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ePBry-0005rb-8j for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Dec 2017 18:35:02 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ePBrx-0005rB-QK for pgsql-hackers@lists.postgresql.org; Wed, 13 Dec 2017 18:35:02 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ePBrt-0005bO-Tx for pgsql-hackers@postgresql.org; Wed, 13 Dec 2017 18:35:00 +0000 Received: by mail-wr0-x241.google.com with SMTP id o2so2955701wro.5 for ; Wed, 13 Dec 2017 10:34:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=jszCi5aCN89S+eO2789tlIWurUqHDW1AZbyDxDlGKTU=; b=RTDe0UkownJqMTi2CzZqZBZogf6kFX8ONld8bKejb1dwLGYcjSEIxI8rP5kUYdR7PN oqLo1EZarmIzCISH/wePVWvK0rTnqx7NGFp+EkyjP3QL0MONC0t2PiwxlL2C7ZNt/OYd Hz1AapB4RS5xL0S3Fmj1blE+JbGYh7e6zI2FDs6pzQQHT3ne7ghHJdOvEYC2/imrDFx8 qaej3gup2pU/ZjIUdRxgxk+bCMErTmJh2rWxYOvyTGaA0N1JBClX3fdCD+SckTQuvYHX Hngn75kyXLGY9taI6CGbxw4c08SbkOs0gYI2sviVnjaXZFXLi4JPT4hJfRyrz9VWl5io 7ufQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=jszCi5aCN89S+eO2789tlIWurUqHDW1AZbyDxDlGKTU=; b=i6uaellPxfFvVbHGmW7/km3BwNH2SNVexH4PMtCG0HQfH6PZFM3R2I6XnsqCnfSuLw Qk/lvj2Oycj8Z8kbE6eHjuPZBMbD4lSZPg+hl/4DH8eK1vlySyocpwxL1LDtSidvlyQz CI6GN8AaAGidgvYTgRmzHjDT5uRYh5Ad4Hz8DrqR/e8tG/OiloYzBTXk+swSGd95LhJ3 b9EiScMqN4/hM6MLquxOfEsZsP76n18MIp755JQS6AQqlC2X+8aA6FKbn/CiLBZUuLn8 09hqNTFZUvCIrtBujnqyvbOt8reicF5kLkgkdbRuZtR0kRjn8wuqciCIONbzfGwVJbXv +Jhg== X-Gm-Message-State: AKGB3mI5yAynhwCK1MnBqZaDinqQJAxiQh7xoNeC6juzJMxmHQ10bc0i bxox99+d0LEyytZCFaLsV4YrU31PuHqTcyJz/lmicjUVJ/TXFowFVs7pK/a0dLM7gt7Z8t+CKum NRUOpP8juvyPDynZxDx4wQP55V3EFr49Bs6TQm+82qstOIDtKymeBUVgMeokIbMHZp0g/glHxtr AB/9pLC+MC X-Google-Smtp-Source: ACJfBosavQQVhTxxO25HSD9WyH76ktyDV9VRAbhVt4rP0EP2ZBx0Yas2PotCgENw2RzOU5axQtyU/g== X-Received: by 10.223.196.247 with SMTP id o52mr3212730wrf.119.1513190094495; Wed, 13 Dec 2017 10:34:54 -0800 (PST) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id p72sm960254wme.17.2017.12.13.10.34.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 10:34:53 -0800 (PST) Subject: Re: [HACKERS] Custom compression methods To: Alvaro Herrera Cc: Robert Haas , Ildus Kurbangaliev , "pgsql-hackers@postgresql.org" References: <20171213165501.rita5g7kepdcimwr@alvherre.pgsql> From: Tomas Vondra Message-ID: <3cc48e8f-8d07-b5f9-ff13-dcfd3e0ec169@2ndquadrant.com> Date: Wed, 13 Dec 2017 19:34:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20171213165501.rita5g7kepdcimwr@alvherre.pgsql> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 12/13/2017 05:55 PM, Alvaro Herrera wrote: > Tomas Vondra wrote: > >> On 12/13/2017 01:54 AM, Robert Haas wrote: > >>> 3. Compression is only applied to large-ish values. If you are just >>> making the data type representation more compact, you probably want to >>> apply the new representation to all values. If you are compressing in >>> the sense that the original data gets smaller but harder to interpret, >>> then you probably only want to apply the technique where the value is >>> already pretty wide, and maybe respect the user's configured storage >>> attributes. TOAST knows about some of that kind of stuff. >> >> Good point. One such parameter that I really miss is compression level. >> I can imagine tuning it through CREATE COMPRESSION METHOD, but it does >> not seem quite possible with compression happening in a datatype. > > Hmm, actually isn't that the sort of thing that you would tweak using a > column-level option instead of a compression method? > ALTER TABLE ALTER COLUMN SET (compression_level=123) > The only thing we need for this is to make tuptoaster.c aware of the > need to check for a parameter. > Wouldn't that require some universal compression level, shared by all supported compression algorithms? I don't think there is such thing. Defining it should not be extremely difficult, although I'm sure there will be some cumbersome cases. For example what if an algorithm "a" supports compression levels 0-10, and algorithm "b" only supports 0-3? You may define 11 "universal" compression levels, and map the four levels for "b" to that (how). But then everyone has to understand how that "universal" mapping is defined. Another issue is that there are algorithms without a compression level (e.g. pglz does not have one, AFAICS), or with somewhat definition (lz4 does not have levels, and instead has "acceleration" which may be an arbitrary positive integer, so not really compatible with "universal" compression level). So to me the ALTER TABLE ALTER COLUMN SET (compression_level=123) seems more like an unnecessary hurdle ... >>> I don't think TOAST needs to be entirely transparent for the >>> datatypes. We've already dipped our toe in the water by allowing some >>> operations on "short" varlenas, and there's really nothing to prevent >>> a given datatype from going further. The OID problem you mentioned >>> would presumably be solved by hard-coding the OIDs for any built-in, >>> privileged compression methods. >> >> Stupid question, but what do you mean by "short" varlenas? > > Those are varlenas with 1-byte header rather than the standard 4-byte > header. > OK, that's what I thought. But that is still pretty transparent to the data types, no? regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services