Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eehBh-0003ZR-Al for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jan 2018 13:03:29 +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 1eehBg-0008Sn-P3 for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jan 2018 13:03:28 +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 1eehBg-0008Sd-BJ for pgsql-hackers@lists.postgresql.org; Thu, 25 Jan 2018 13:03:28 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eehBc-0001HY-9D for pgsql-hackers@postgresql.org; Thu, 25 Jan 2018 13:03:27 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 1DC2421C1C42; Thu, 25 Jan 2018 16:03:21 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.27.109] (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id B5C4421C1751; Thu, 25 Jan 2018 16:03:20 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1516885400; bh=pWAXQU8EzJNAHmwBfllrbTuPIVKGGm8Hfy8fTtV3pT8=; h=Subject:To:References:Cc:From:Date:In-Reply-To; b=Riq6t1nu6tHkxbrYC8kbcypZijpkmOc7L4p5KpZJcPXc4gNFDEGYc5MrRX1rVy5sL ddQpQckQXwTLb1GzP2J4pc+aR+lajj6CFKZ2Edl83eAILfpKs9yJr3pWGbo9OC5NEG fLs15J/mK2Hr/rXKUuRe9xzgKIPxOJtfurk3UAA0= Subject: Re: [HACKERS] Custom compression methods To: Ildus Kurbangaliev References: <20171201194859.le5hvnnrjzhxhm2t@alvherre.pgsql> <20171206180716.75ba9ba9@postgrespro.ru> <20171211155555.05ddd2fc@postgrespro.ru> <20171213151818.75a20259@postgrespro.ru> <20171218115431.2b3e29ba@wp.localdomain> <20180115024930.48583c69@hh> <0633c6e5-5328-5c5b-708b-c4409e3fd131@postgrespro.ru> <20180123160454.131ade09@wp.localdomain> Cc: Robert Haas , Alexander Korotkov , Tomas Vondra , Alvaro Herrera , =?UTF-8?B?0JXQstCz0LXQvdC40Lkg0KjQuNGI0LrQuNC9?= , Andres Freund , Oleg Bartunov , Craig Ringer , Peter Eisentraut , PostgreSQL Hackers , Chapman Flack From: Ildar Musin Message-ID: <6fd5dea3-8889-c7bb-9df2-79493b2b6ab0@postgrespro.ru> Date: Thu, 25 Jan 2018 16:03:20 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <20180123160454.131ade09@wp.localdomain> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello Ildus, On 23.01.2018 16:04, Ildus Kurbangaliev wrote: > On Mon, 22 Jan 2018 23:26:31 +0300 > Ildar Musin wrote: > > Thanks for review! Attached new version of the patch. Fixed few bugs, > added more documentation and rebased to current master. > >> You need to rebase to the latest master, there are some conflicts. >> I've applied it to the three days old master to try it. > > Done. > >> >> As I can see the documentation is not yet complete. For example, there >> is no section for ALTER COLUMN ... SET COMPRESSION in ddl.sgml; and >> section "Compression Access Method Functions" in compression-am.sgml >> hasn't been finished. > > Not sure about ddl.sgml, it contains more common things, but since > postgres contains only pglz by default there is not much to show. > >> >> I've implemented an extension [1] to understand the way developer >> would go to work with new infrastructure. And for me it seems clear. >> (Except that it took me some effort to wrap my mind around varlena >> macros but it is probably a different topic). >> >> I noticed that you haven't cover 'cmdrop' in the regression tests and >> I saw the previous discussion about it. Have you considered using >> event triggers to handle the drop of column compression instead of >> 'cmdrop' function? This way you would kill two birds with one stone: >> it still provides sufficient infrastructure to catch those events >> (and it something postgres already has for different kinds of ddl >> commands) and it would be easier to test. > > I have added support for event triggers for ALTER SET COMPRESSION in > current version. Event trigger on ALTER can be used to replace cmdrop > function but it will be far from trivial. There is not easy way to > understand that's attribute compression is really dropping in the > command. > I've encountered unexpected behavior in command 'CREATE TABLE ... (LIKE ...)'. It seems that it copies compression settings of the table attributes no matter which INCLUDING options are specified. E.g. create table xxx(id serial, msg text compression pg_lz4); alter table xxx alter column msg set storage external; \d+ xxx Table "public.xxx" Column | Type | ... | Storage | Compression | --------+---------+ ... +----------+-------------+ id | integer | ... | plain | | msg | text | ... | external | pg_lz4 | Now copy the table structure with "INCLUDING ALL": create table yyy (like xxx including all); \d+ yyy Table "public.yyy" Column | Type | ... | Storage | Compression | --------+---------+ ... +----------+-------------+ id | integer | ... | plain | | msg | text | ... | external | pg_lz4 | And now copy without "INCLUDING ALL": create table zzz (like xxx); \d+ zzz Table "public.zzz" Column | Type | ... | Storage | Compression | --------+---------+ ... +----------+-------------+ id | integer | ... | plain | | msg | text | ... | extended | pg_lz4 | As you see, compression option is copied anyway. I suggest adding new INCLUDING COMPRESSION option to enable user to explicitly specify whether they want or not to copy compression settings. I found a few phrases in documentation that can be improved. But the documentation should be checked by a native speaker. In compression-am.sgml: "an compression access method" -> "a compression access method" "compression method method" -> "compression method" "compability" -> "compatibility" Probably "local-backend cached state" would be better to replace with "per backend cached state"? "Useful to store the parsed view of the compression options" -> "It could be useful for example to cache compression options" "and stores result of" -> "and stores the result of" "Called when CompressionAmOptions is creating." -> "Called when CompressionAmOptions is being initialized" "Note that in any system cache invalidation related with pg_attr_compression relation the options will be cleaned" -> "Note that any pg_attr_compression relation invalidation will cause all the cached acstate options cleared." "Function used to ..." -> "Function is used to ..." I think it would be nice to mention custom compression methods in storage.sgml. At this moment it only mentions built-in pglz compression. -- Ildar Musin i.musin@postgrespro.ru